gabo84
gabo84

Reputation: 233

ffmpeg setting for HD and normal quality

Hello i need to have two versions of the same file stored on my server, medium and HD quality, the thing is that don't really know ffmpeg that well so im just trying this is code at random, i'm using the code belo but I end up with a much larger file, however it works,it plays.

ffmpeg -i inputfile.wmv  -vcodec libx264 -ar 44100 -b 200 -ab 56 -crf 22 -s 360x288 -vpre medium -f flv tmp.flv

Just need the two commands to create the 2 different files

Upvotes: 3

Views: 17271

Answers (1)

Joakim Nohlgård
Joakim Nohlgård

Reputation: 1852

You need to give more information about what bitrate, quality or target file size you are aiming for and the size and quality of your source material preferably including codecs used and relevant parameters.

You should read the manual or ffmpeg -h or both. There are several problems with your command line:

  • You are using constant rate factor, crf = 22, while still trying to limit the bitrate using -b 200.
  • Bitrate is specified in bits/s (unless you are using a very old ffmpeg), and 200 bps is not usable for anything, add k to get kilobits/s.
  • You have not specified an audio codec, but you have specified an audio bitrate, ffmpeg will try to guess the audio codec for you but I don't know what codec is the default for .flv-files.

I'm assuming that the command line you posted is supposed to be for the 'medium' quality file.

Some suggestions that you can try:

  1. Try this first: specify audio codec, e.g. -acodec libmp3lame, or if the audio is already in a good format you can just copy it without modification using -acodec copy
  2. Try a different rate factor, e.g. -crf 30, higher numbers mean uglier picture quality, but also smaller file size.
  3. Try a different encoder preset, e.g. -vpre slow, in general, the slower presets enable features that require more CPU cycles when encoding but results in a better picture quality, see x264 --fullhelp or this page to see what each preset contains.
  4. Do a 2-pass encode, link.

If you don't want to read all the documentation for ffmpeg and the codec parameters that you need I suggest you look at this cheat sheet, although the command line switches have changed over the different versions of ffmpeg so the examples might not work.

An example command line:

ffmpeg -i inputfile.wmv  -vcodec libx264 -crf 25 -s 360x288 -vpre veryslow -acodec libmp3lame -ar 44100 -ab 56k -f flv tmp.flv

The parameter -s [size] is the size of the output video, in pixels, for the HD file you probably want something around 1280x720, if your material is 5:4 ratio (as 360x288 is) you'll want to try 1280x1024, 960x768 or 900x720. Don't set a size larger than the source material as that will simply upscale the video and you will (probably) end up with a larger file without any noticeable improvement in quality. The -ab parameter is the audio bitrate, you'll probably want to increase this parameter on the HD version as well.

Upvotes: 4

Related Questions