ffmpeg is a mighty tool for dealing with videos. Around the ffmpeg core is a rich ecosystem with video-editing related tools. First, we look at some handy examples to get a feeling how to deal with ffmpeg.

Converting different file formats

Getting basic information about a video is as easy as:

Converting an mp4-video to an avi-video with ffmpeg:

The quality of the output can be defined as well with a number between 1 (high quality) and 50 (low quality). If you output-video is an avi you use the -p parameter. If your output-video is mp4 you use the parameter -crf instead. Have a look at the exmaple:

Use ffmpeg to convert an input-video to an output-video and set the framerate (parameter -r) of the output video to 5 frames:

Scaling a video can be done with ffmpeg as well. Use the scale video filter. This filter has two parameters, notice that the second one is -1, this means that the scaling for the y-axis is proportional.

Changing colors by using ffmpeg video filters

Convert input video to a greyscale output video with ffmpeg (see the -vf videofilter parameter):

Convert input video to a sepia output video with ffmpeg:

Joining (concatenate) and cutting videos

Cutting video with ffmpeg is simple. You want to specify a start and end time to convert only a certain timeslice? No Problem. The parameter -ss 30:15 let the video start at 30 minutes and 15 seconds. The parameter -t 40 defines the length. Take care of the parameters orders. This example cuts a 40-second lasting piece and starts at 30 min and 15 seconds:

You can even join (concatenate) videos together with ffmpeg. Concat two avi-videos together can be done with this command:

Joining mp4-videos doesn’t work the before mentioned way. Here we first create some intermediate ts files and join them afterwards:


Caturing video from webcam with ffmpeg

Capturing video from a webcam with ffmpeg and store it in output-video.
(It is important to know the name of your webcam device. In my case, it is /dev/video0 under linux. You can research this with the command: ffmpeg -sources)