ffmpeg examples

75
rate or flag this page
Facebook

By rhughes2832

 

ffmpeg is a great command line tool for converting between video and audio formats. But good examples are hard to find.

(more ffmpeg examples on my site www.smallsoftware.co.uk)

My main use of ffmpeg is for converting MPEG2 files (typically recorded from DVB-T/Freeview) either into DivX (to play on an Archos portable video player), or lower bitrate MPEG2. When I was learning to use it, I was constantly frustrated by the lack of good examples for commonly used video format. If you're looking for something similar, hopefully this will be useful to you.

Convert to DivX

This creates a DivX file, 4:3 aspect ratio, 320x240 resolution, bit rate of 690k for video, 128k for audio. The right sort of size for my Archos AV420 player.

ffmpeg -i inputfile.mpg   -vtag DIVX -f avi -vcodec mpeg4 
     -aspect 4:3 -s 320x240  -b 690000 -acodec mp3 
     -ab 128000 -ar 48000 -ac 2  outputfile.avi
 

and the same thing for 16:9 ratio.

ffmpeg -i inputfile.mpg   -vtag DIVX -f avi -vcodec mpeg4 
     -aspect 16:9 -s 320x192 -b 690000 -acodec mp3 
     -ab 128000 -ar 48000 -ac 2  outputfile.avi
 
 

Convert lower-rate MPEG2

I've got a Netgem iPlayer in the kitchen for the children to watch cartoons on. Cartoons don't need a very high bitrate (and the children are too small to care about a bit of pixellation anyway), so I lower the bitrate to save disk space (I've still got more than 200Gb of cartoons though...).

This will lower the bitrate to 1536k... that's equivalent to about 5 hours on a single layer DVD. At that low a rate, it's best to take a little longer doing the encoding, so I do two passes.

ffmpeg -i inputfile.mpg -vcodec  mpeg2video -b 1536000 
     -ab 128000 -ar 48000 -ac 2 -pass 1 outputfile.mpg 
 
rm outputfile.mpg 
 
ffmpeg -i inputfile.mpg -vcodec  mpeg2video -b 1536000 
     -ab 128000 -ar 48000 -ac 2 -pass 2 outputfile.mpg

Comments

tambrab2007 profile image

tambrab2007 3 years ago

Divx works fine for this, but I do think that AVS tools works much better; however, that is just my opinion.

The Bear 2 years ago

tambrab2007, why would you use a jackhammer where a pick is ample?

50 MB vs. 70KB and besides, what's the point of trying to push M$ Windoze software at Linux People.. NOT bloody much, go back to your Virus Ridden, Crash Prone Trojan and let REAL computer users use REAL software NOT useless BLOATWARE.

Just because MS-Window's holds 90% of the market doesn't mean it's superior. Remember 90% of all animals are insects.

dfgdf 2 years ago

* Please enter your name before posting.

* Please enter a comment before posting.

Amir 2 years ago

Hi,

How can I download ffmpeg.exe file or how can I produce the file?

Marcus 11 months ago

Thanks very much for your useful examples here. The first DIVX example was exactly what I was looking for. I bought a Sony DVD player some years back hoping that I could play MPEG4 AVI, only to find that it insisted on having "genuine DIVX" encoded files before it would work. Your example with the -vtag DIVX worked wonderfully :)

jas 11 months ago

"The Bear 2 years ago

tambrab2007, why would you use a jackhammer where a pick is ample?

50 MB vs. 70KB and besides, what's the point of trying to push M$ Windoze software at Linux People.. NOT bloody much, go back to your Virus Ridden, Crash Prone Trojan and let REAL computer users use REAL software NOT useless BLOATWARE.

Just because MS-Window's holds 90% of the market doesn't mean it's superior. Remember 90% of all animals are insects."

boy, angry much? do you have a blocked colon or something?

someman7 5 months ago

LOLWUT? That can't be right. Your remove your "first pass". A more likely scenario is that you first encode with a single pass, remove the result, and then do it with a double pass

Thank you! 5 months ago

Thank you!!!!!!!!!

Submit a Comment
Members and Guests

Sign in or sign up and post using a hubpages account.



    • No HTML is allowed in comments, but URLs will be hyperlinked
    • Comments are not for promoting your Hubs or other sites

    working