Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have problems with ffmpeg on OSX Lion. I am trying to convert the mpeg file and the output is always a file of size 400kb or so..

The command is:

 ffmpeg -i out_poem_big.mpg -s 1280x720 -vpre medium outvideo.mp4

Here is the log:

FFmpeg version 0.6.3, Copyright (c) 2000-2010 the FFmpeg developers
  built on Feb 21 2012 21:57:04 with gcc 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
  configuration: --disable-debug --prefix=/usr/local/Cellar/ffmpeg/0.6.3 --enable-shared --enable-pthreads --enable-nonfree --enable-gpl --disable-indev=jack --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libxvid --enable-libfaad
  libavutil     50.15. 1 / 50.15. 1
  libavcodec    52.72. 2 / 52.72. 2
  libavformat   52.64. 2 / 52.64. 2
  libavdevice   52. 2. 0 / 52. 2. 0
  libswscale     0.11. 0 /  0.11. 0

Seems stream 0 codec frame rate differs from container frame rate: 59.94 (60000/1001) -> 29.97 (60000/2002)
Input #0, mpeg, from 'out_poem_big.mpg':
  Duration: 00:08:35.61, start: 1.000000, bitrate: 14823 kb/s
    Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 104857 kb/s, 28.90 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0.1[0x1c0]: Audio: mp2, 44100 Hz, 2 channels, s16, 128 kb/s
File 'outvideo.mp4' already exists. Overwrite ? [y/N] y
[libx264 @ 0x7fb7ca033600]using SAR=1/1
[libx264 @ 0x7fb7ca033600]using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
[libx264 @ 0x7fb7ca033600]profile High, level 3.1
[libx264 @ 0x7fb7ca033600]264 - core 120 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=200 ratetol=20.0 qcomp=0.60 qpmin=10 qpmax=51 qpstep=4 ip_ratio=1.41 aq=1:1.00
Output #0, mp4, to 'outvideo.mp4':
    encoder         : Lavf52.64.2
    Stream #0.0: Video: libx264, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], q=10-51, 200 kb/s, 60k tbn, 29.97 tbc
    Stream #0.1: Audio: libfaac, 44100 Hz, 2 channels, s16, 64 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
Press [q] to stop encoding
Input Stream #0.0 frame size changed to 1920x1080, yuv420p

I tried all sorts of vcodec and the output is the same at best, also tried -sameq but no luck.

ffmpeg was installed via homebrew

share|improve this question
Is it just this file or ffmpeg in general? Would you mind posting a similar file that you're having difficulty with somewhere public for us to test? –  fideli Feb 22 '12 at 4:53
can we see file /usr.local/share/ffmpeg/libx264-medium.ffpreset - the parameter template you are using? Maybe it sets own video size or needs dimensions divisible by 64 pixels or so? –  ZaB Feb 22 '12 at 9:18
@ZaB The video size is fine, look at the output stream #0.0. The bit rate is too low, as you can see. Also, ffpresets shouldn't really be used anyway. –  slhck Feb 22 '12 at 9:54
add comment

1 Answer

up vote 2 down vote accepted

There are a few things I'd like to point out:

  • Upgrade your version of FFmpeg. It's terribly outdated. Run brew update and then brew upgrade to do so. FFmpeg 0.9 introduced a new way of specifying encoding presets, and the one you're currently using is just legacy.

  • Don't ever use sameq. It does not mean same quality. It basically means, use the same mathematical options that were used in the input video, which in fact drastically reduces quality.

Where your problem is …

Let's get to the issue at hand. The output video has a bit rate of ~200 kBit/s, but your input has 14823 kBit/s. This is why it looks so bad. It now depends on what you want to do. If you just want to change the container to MP4, use -vcodec copy and be done with it.

If you want to change the frame size, use something like the following:

ffmpeg -i out_poem_big.mpg -c:v libx264 -preset slow -crf 22 -s 1280x720 -c:a libfaac -b:a 128K outvideo.mp4

What does that mean?

  • Most important aspect here is -crf 22, the Constant Rate Factor. Make it lower for better quality, make it larger for worse quality. See this answer for a more thorough explanation of what it means.

    If you need a constant output bit rate, replace -crf 22 with -b:v 1M, for example. Note though that constant bit rate results in worse quality due to the way x264 handles it.

  • -c:v is used instead of -vcodec. It means the same, but this is the default format and I'd prefer to stick to this. Also, we explicitly want libx264 since all other encoders will likely reduce the quality you get for file size (like MPEG-4 Part II, -c:v mpeg4).

  • -preset slow will use a slow variant of encoding with more bit-efficient optimization.

  • I specified the audio codec and audio bitrate. Change it accordingly, depending on what you want to use.

  • See these answer for more explanation about FFmpeg encoding:

share|improve this answer
Wow! Super thanks. –  user861181 Feb 22 '12 at 19:31
Problem is that when I do brew ffmpeg upgrade I get ffmpeg already upgraded... Does it mean I am stuck with 0.6.3 as long as I use brew? –  user861181 Feb 22 '12 at 21:02
Did you do brew update before? If that doesn't work, uninstall it with brew remove ffmpeg x264 and install again. –  slhck Feb 22 '12 at 21:11
just did it and it keeps installing 0.6.3...? –  user861181 Feb 22 '12 at 21:39
ok so it may not be the best solution, but I did this: $ cd (tilda)brew --prefix(tilda) $ git checkout fb01c6e /usr/local/Library/Formula/ffmpeg.rb $ brew uninstall ffmpeg $ brew install ffmpeg Had to $ brew install x264 as well. There were some linking problems, but they got resolved by $ sudo brew link ffmpeg –  user861181 Feb 23 '12 at 0:06
show 2 more comments

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.