FFMPEG Cheatsheet List of Useful Commands For Video,Audio & Image Processing For Developers



FFmpeg cheat sheet

A list of useful commands for the ffmpeg command line tool.

Download FFmpeg: https://www.ffmpeg.org/download.html

Full documentation: https://www.ffmpeg.org/ffmpeg.html

Basic conversion

Remux an MKV file into MP4

High-quality encoding

Use the crf (Constant Rate Factor) parameter to control the output quality. The lower crf, the higher the quality (range: 0-51). The default value is 23, and visually lossless compression corresponds to -crf 18. Use the preset parameter to control the speed of the compression process. Additional info: https://trac.ffmpeg.org/wiki/Encode/H.264


Without re-encoding:

  • -ss specifies the start time, e.g. 00:01:23.000 or 83 (in seconds)
  • -t specifies the duration of the clip (same format).
  • Recent ffmpeg also has a flag to supply the end time with -to.
  • -c copy copies the first video, audio, and subtitle bitstream from the input to the output file without re-encoding them. This won’t harm the quality and make the command run within seconds.

With re-encoding:

If you leave out the -c copy option, ffmpeg will automatically re-encode the output video and audio according to the format you chose. For high quality video and audio, read the x264 Encoding Guide and the AAC Encoding Guide, respectively.

For example:

Mux video and audio from another video

To copy the video from in0.mp4 and audio from in1.mp4:

Concat demuxer

First, make a text file.

Then, run ffmpeg:

Delay audio/video

Delay video by 3.84 seconds:

Delay audio by 3.84 seconds:

Burn subtitles

Use the libass library (make sure your ffmpeg install has the library in the configuration --enable-libass).

First convert the subtitles to .ass format:

Then add them using a video filter:

Extract the frames from a video

To extract all frames from between 1 and 5 seconds, and also between 11 and 15 seconds:

To extract one frame per second only:

Rotate a video

Rotate 90 clockwise:

For the transpose parameter you can pass:

Use -vf "transpose=2,transpose=2" for 180 degrees.

Download “Transport Stream” video streams

  1. Locate the playlist file, e.g. using Chrome > F12 > Network > Filter: m3u8
  2. Download and concatenate the video fragments:

If you get a “Protocol ‘https not on whitelist ‘file,crypto’!” error, add the protocol_whitelist option:

Mute some of the audio

To replace the first 90 seconds of audio with silence:

To replace all audio between 1’20” and 1’30” with silence:


Deinterlacing using “yet another deinterlacing filter”.

Create a video slideshow from images

Parameters: -r marks the image framerate (inverse time of each image); -vf fps=25 marks the true framerate of the output.

Extract images from a video

  • Extract all frames: ffmpeg -i input.mp4 thumb%04d.jpg -hide_banner
  • Extract a frame each second: ffmpeg -i input.mp4 -vf fps=1 thumb%04d.jpg -hide_banner
  • Extract only one frame: ffmpeg -i input.mp4 -ss 00:00:10.000 -vframes 1 thumb.jpg

Metadata: Change the title

Leave a Reply