ls whoami I'm Siegfried. A developer. Yep. en fr jp

FFmpeg tips

Here are a few commands for FFmpeg that were useful for me.

The help page for all parameters is here.

A nice tool that uses FFmpeg is Handbrake.

Get some info about a file

ffmpeg -i video.mp4

Parameters:

  • ffmpeg is the ffmpeg command :p
  • -i video.mp4 specifies the input file

Extract the audio part of a video

ffmpeg -i video.mp4 -vn -acodec copy audio.m4a

Parameters:

  • -vn disables the video
  • -acodec copy allows to copy the audio stream without touching it
  • audio.m4a is the output file

Convert an audio file to another format

ffmpeg -i audio.m4a -acodec libmp3lame -ac 0 -ab 320k audio.mp3

Parameters:

  • -acodec libmp3lame allows to use the lame mp3 library for conversion
  • -ac 2 sets the number of channels
  • -ab 320k sets the bitrate

Of course, the previous command and this one can be merged for a 1 step audio extraction & conversion.

Crop a video

ffmpeg -i video.mp4 -vf "crop=760:430:520:0" output.mp4

Parameters:

  • -vf "crop=760:430:520:0" applies a filter on the video. The values for the “crop” are: width:height:left:top.

Pro-tip: use ffplay to preview the cropped area !

ffplay -i video.mp4 -vf "crop=760:430:520:0"

Create a gif from a video

ffmpeg -i dauphin.mp4 -r 10 dauphin.gif

Parameters:

  • -r 10 sets the framerate