PDA

View Full Version : Question concerning equivalency of ffmpeg/x264 options


Dust Signs
13th January 2009, 07:57
Hi,

as I need to convert MPEG-2 to H.264 (video only, no audio) for a test scenario in the company I'm working for, I tried both using ffmpeg with --enable-libx264 as well as ffmpeg outputting raw video data to x264 over a pipe. Here are the commands I used:

./ffmpeg -y -deinterlace -itsoffset -600 -i /home/testuser/x264test/test/snippet.mpg -t 30 -vcodec libx264 -level 41 -b 2000000 -bf 3 -b_strategy 1 -qmax 51 -trellis 2 -refs 2 -b_strategy 1 -flags2 +bpyramid+dct8x8 -f rawvideo -an /home/testuser/x264test/test/test_direct.264

./ffmpeg -deinterlace -itsoffset -600 -i /home/testuser/x264test/test/snippet.mpg -t 30 -f rawvideo - | x264 -o /home/testuser/x264test/test/test.264 - 720x576 --bitrate 2000 --sar 4:3 --level 4.1 --trellis 2 -8 --b-pyramid --ref 2 --b-adapt 1 --progress

I used this page to get the corresponding ffmpeg/x264 options: http://ffmpeg.x264.googlepages.com/mapping
The problem now is that
* The ffmpeg with libx264 encode looks significantly worse compared to the other one
* There is a difference of about 100kBit/s between both encodes (which I assume can be at least reduced using the bit rate tolerance parameters, but this is not crucial at the moment)
* Using pipes, encoding is about 150% faster (6fps compared to 2,5fps using ffmpeg with libx264)

I compiled x264 and ffmpeg myself, using yesterday's sources of both. Did I miss anything in my configuration or are there any default values which I did not consider? Does anyone have any idea why there is such a discrepancy between the two approaches?

Dust Signs

PS.: I'm sorry that I can't post any samples as I'm not allowed to

Dark Shikari
13th January 2009, 09:34
Perhaps I need to make it even more obvious in the various guides, but ffmpeg defaults are totally broken. Don't use them ever.

-vpre hq exists for a reason.

Dust Signs
13th January 2009, 09:44
Hi Dark Shikari,

thanks for the information, I didn't know that. Is there any preset which sets the defaults x264 is using? The "hq" preset is not exactly what I'm looking for as it slows down encoding and seems not to be using the same default values as x264 does. The main aim is to achieve a configuration which is equal (or at least very similar) to the pipe version.

Dust Signs

Dark Shikari
13th January 2009, 09:46
Hi Dark Shikari,

thanks for the information, I didn't know that. Is there any preset which sets the defaults x264 is using? The "hq" preset is not exactly what I'm looking for as it slows down encoding and seems not to be using the same default values as x264 does.If you want, for reference, the exact same settings that x264 has as defaults, the "default" preset is what you want... but you generally shouldn't be using defaults, which is why I recommended hq.

Dust Signs
13th January 2009, 10:19
Maybe I should also note that my experiments are related to live broadcasting, so the hq preset does not seem to be the best choice as it is too slow. Is there another profile you would recommend for this purpose?

Dust Signs

Dark Shikari
13th January 2009, 13:25
Maybe I should also note that my experiments are related to live broadcasting, so the hq preset does not seem to be the best choice as it is too slow. Is there another profile you would recommend for this purpose?

Dust SignsStart with "normal", and go down from there until things are fast enough.

Things you can drop from there:

directpred -> 1
refs -> 1
bf -> 1 and b_strategy -> 0 and sc_threshold -> -1 (no-b-adapt, helpful if you're bottlenecked on an 8-core system)
partitions -> i4x4, i8x8 (helpful on messy sources and lower bitrates where p8x8/b8x8 aren't very useful and you need more speed)
and of course dropping subq.

Dust Signs
13th January 2009, 13:32
Thank you very much for your help. I think that I now have a good starting point for further testing :)

Thanks a lot
Dust Signs