ffmpeg command line examples

Convert MP4 to Webm

Constant bitrate

ffmpeg -i input.mp4 -c:v libvpx -minrate 1M -maxrate 1M -b:v 1M output.webm

Varible bitrate

ffmpeg -i input.mp4 -c:v libvpx -qmin 0 -qmax 20 output.webm
ffmpeg -i input.mp4 -c:v libvpx -crf 10 -b:v 2M output.webm
ffmpeg -i input.mp4 -c:v libvpx -qmin 0 -qmax 50 -crf 10 -b:v 2M output.webm
ffmpeg -i input.mp4 … -c:a libvorbis -q:a 4 output.webm

Convert WAV to MP3

Converts WAV to various MP3 formats

~ $ ffmpeg -i source.wav -b:a 128k output.mp3
~ $ ffmpeg -i source.wav -b:a 192k output.mp3

Convert Audio for FreeSWITCH (or Asterisk)

Converts WAV to various MP3 formats

~ $ ffmpeg -i source.mp3 \
    -ar 8000 -ac 1 -ab 64 output.wav \
    -ar 8000 -ac 1 -ab 64 -f mulaw output.pcm \
    -map 0:0 -map 0:0

Slice Part of Video

ffmpeg -f h264 -i input-video-file.264 -ss 180 -t 8 output-video-file.mp4

Source framerate is funny? Specify it

ffmpeg -f h264 -r:v 7 -i input-video-file.264 -ss 180 -t 8 output-video-file.mp4

Adjust Playback Speed

Speed Up Video

fmpeg -i source.webm -vf "setpts=0.5*PTS" target.webm

Slow Down Video

ffmpeg -i source.webm -vf "setpts=2.0*PTS" target.webm

See Also