Bookmark and Share

Convert mp4 to avi

$ ffmpeg -i infile.mp4 outfile.avi

Resize a video or image

Resize a video such that its width is 1080 pixels and the aspect ratio is maintained, hence the height parameter is -1:

$ ffmpeg -i input.mp4 -vf scale=1080:-1 output.mp4

Convert to a specificed bitrate

$ ffmpeg -i input.avi -b 64k output.avi

Convert WAV audio file to MP3 format at a specified audio bitrate

$ ffmpeg -i input.wav -acodec mp3 -ab 128k output.mp3

Convert mp3 audio file to Orbvis format at a specified audio bitrate

$ ffmpeg -i input.mp3 -acodec libvorbis -crf 15 output.ogg
  • -crf: Use Constant Rate Factor to keep the best quality and don't care about the file size. The range of the CRF scale is 0–51, where 0 is lossless, 23 is the default, and 51 is worst quality possible.

Convert avi file to specified audio sampling rate (22050 Hz), audio bitrate (32 kbps), and frame size (640x480)

$ ffmpeg -i input.avi -ar 22050 -ab 32 -s 640×480 video.mp4

One can use named frame sizes such as

-s vga

Combine multiple files into one file

$ ffmpeg -safe 0 -f concat -i ./my_file_list.txt -c copy output_file.mp3

my_file_list.txt is

# some comment
file './part_file_1.mp3'
file './part_file_2.mp3'
file './part_file_3.mp3'

Trim a video or audio according to starting and ending times

ffmpeg -ss hh:mm:ss -to hh:mm:ss -i 'input.mp4' -c copy output.mp4

Options

See formats and codecs available on your computer

$ ffmpeg -formats

References

External links

blog comments powered by Disqus