Following this official restream.io guide, I would like a person with some ffmpeg experience to translate this page into an ffmpeg command in order to save us, linux users, from having to install HandBrake just for video transcoding (I believe transcoding is the word that this guide wants us to do).

The desired video output seems to be (please, compare and give me some feedback for correctness):

  • MP4 (?)
  • 720p
  • 30 FPS
  • Web Optimized - Optimize MP4 for progressive download. After encoding, data is reorganized and rewritten, to allow immediate playback over a network, without needing to download the entire file
  • 1280x720 or 960x540
  • Video codec: H.264 (x264)
  • Constant framerate
  • bitrate: 4000 kbit/s or 800 kbit/s
  • encoder preset: medium or veryfast
  • keyframe interval: every 2 seconds ==> 60 or keyint=60 (not sure if keyint helps clarify some doubts)

1 Answer 1


You can try:

ffmpeg -i <input_path> -c:v libx264 -r 30 -s 1280x720 -force_key_frames expr:gte(t,n_forced*2) <output_path>

I'm not sure if this will meet your needs exactly, but then again I am not an ffmpeg expert, just an occasional user.

  • what does expr:gte(t,n_forced*5) mean? Thank you for responding @VicerExciser Commented Sep 5, 2020 at 14:48
  • Sorry, that is the value for the -force_key_frames option that will force a key frame every 5 seconds. If you want every two seconds, it should actually be expr:gte(t,n_forced*2). More details can be found here: ffmpeg.org/ffmpeg.html Commented Sep 10, 2020 at 19:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .