Skip to content

Instantly share code, notes, and snippets.

@roj1512
Last active February 15, 2024 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roj1512/62801dc7a18710c1fe0d0f5c638d4474 to your computer and use it in GitHub Desktop.
Save roj1512/62801dc7a18710c1fe0d0f5c638d4474 to your computer and use it in GitHub Desktop.

The simplest way

ffmpeg -re -i <your_input> -c:v libx264 -c:a aac -f flv <stream_url>/<stream_key>
  • -re reads the input at native frame rate, doing this is recommended by FFmpeg.
  • -c:v libx264 encodes the video of the output in libx264, the required video encoding by Telegram.
  • -c:a aac encodes the audio of the output in aac, the required audio encoding by Telegram.
  • -f flv sets the format of the output to flv, the required format by Telegram.

What if we don’t want to go offline?

Just add -loop to the input options!

ffmpeg -re -loop -i <your_input> -c:v libx264 -c:a aac -f flv <stream_url>/<stream_key>
@thedrint
Copy link

You can use also -c:v h264_nvenc encoding for video (if you have nvidia gpu). Telegram allows h.264 codec for streams.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment