Skip to content

Instantly share code, notes, and snippets.

@rojvv
Last active February 15, 2024 16:01
Show Gist options
  • Save rojvv/62801dc7a18710c1fe0d0f5c638d4474 to your computer and use it in GitHub Desktop.
Save rojvv/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