FFmpeg: 10 video editing commands

FFmpeg, short for "Fast Forward MPEG", is a powerful tool used to process, convert, edit and stream audio and video files.

The tool requires some technical knowledge. While a few packages exist that provide a graphical user interface (GUI) around FFmpeg, it is primarily a "command line" tool. FFmpeg is available on different platforms such as Windows, Linux or macOS.

FFmpeg supports many different multimedia formats and codecs, making it possible to perform a wide variety of operations on audio and video files. It can be used to convert files from one format to another, crop videos, merge multiple video files, rotate videos, adjust playback speed, add subtitles, change audio codec and much more.

We have listed the 10 most likely commands for editing videos with FFmpeg.


Converting video formats:

ffmpeg -i inputvideo.avi outputvideo.mp4


To adjust the video quality:

ffmpeg -i inputvideo.mp4 -crf 18 outputvideo.mp4

(this example sets the "constant rate factor" to 18, which gives a higher quality than the default value of 23)


Cropping videos:

ffmpeg -i inputvideo.mp4 -filter:v "crop=720:480:0:0" outputvideo.mp4

(this example crops the video to 720x480 pixels)


Merging multiple videos:

ffmpeg -i "concat:inputvideo1.mp4|inputvideo2.mp4" -c copy outputvideo.mp4


Rotating videos:

ffmpeg -i inputvideo.mp4 -filter:v "transpose=1" outputvideo.mp4

(this example rotates the video 90 degrees to the left)


To change the playback speed:

ffmpeg -i inputvideo.mp4 -filter:v "setpts=0.5*PTS" outputvideo.mp4

(this example speeds up the video by a factor of 2)


Adding subtitles:

ffmpeg -i inputvideo.mp4 -vf subtitles=subtitles.srt outputvideo.mp4


Changing the audio codec:

ffmpeg -i inputvideo.mp4 -c:v copy -c:a aac outputvideo.mp4


Splitting videos:

ffmpeg -i inputvideo.mp4 -t 00:05:00 -c copy outputvideo1.mp4 -ss 00:05:00 -c copy outputvideo2.mp4

(this example splits the video into two parts, the first 5 minutes and the rest)


To adjust the video resolution:

ffmpeg -i inputvideo.mp4 -vf scale=1280:720 outputvideo.mp4

(this example changes the resolution of the video to 1280x720 pixels)