Convert video files

From Ever changing code
Revision as of 21:28, 27 December 2014 by Pio2pio (talk | contribs) (Created page with "= ffmpeg = The most basic way to use ffmpeg is to use -i yourinputfilename.ext folowed by outputfilename.ext. That's it. This is, seriously, all you need do remember when it ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

ffmpeg

The most basic way to use ffmpeg is to use -i yourinputfilename.ext folowed by outputfilename.ext.

That's it. This is, seriously, all you need do remember when it comes to the most basic (ab)use cases:

ffmpeg -i YourAwesomeMovie.dv YourAwesomeMovie.mp4

This basic example will make ffmpeg detect the input file type. The built-in input detection does work perfectly in 99% of all cases.

This basic example will also make ffmpeg assume what audio and video formats you want for your output file based on the file extension. We asked to output the filename YourAwesomeMovie.mp4. It ends with .mp4.

The .mp4 extension will make ffmpeg assume that you want a file with H.264/AVC video and AAC 2.0 audio. This happens to be the correct values for HTML5 web video in the very (as in extremely) evil proprietary HTML5 video format alternative. Moving on to more advanced encoding

The secret ffmpeg manual page is very long. It contains lots of detailed information about the numerous options available when using this tool. Whole books can be, and probably have been, written about the advanced options listed in the manual page.

Things you may want to tune when encoding include:

  • r to change the frame rate
  • b:v to set the video bitrate
  • b:a to set the audio bitrate

These options can have a huge impact on the quality and the file-size of the resulting file.

A general rule is: You can have low file-size OR high picture quality, but you can NOT have both. You will have to compromise.

This may give you an acceptable quality video file, depending on resolution:

ffmpeg -i YourAwesomeMovie.dv -r 25 -b:a 128k -b:v 4000k YourAwesomeMovie.mp4

..and this will NOT, because 256k is not enough bandwidth for acceptable quality even at small resolutions:

ffmpeg -i YourAwesomeMovie.dv -r 25 -b:a 64k -b:v 256k YourAwesomeMovie.mp4