PDA

View Full Version : speedup ffmpeg | x264 encoding?


yeye69
23rd October 2008, 13:16
Hi all!
I'm newby on encoding, so I need some help.
I have Fedora 9 on PC with:

Intel(R) Core(TM)2 Duo CPU E8500 @ 3.16GHz

x264 0.65.999 cc51047
FFmpeg version SVN-r12191

and I try to encode the file (mediainfo output):

Format : BDAV
Format/Info : BluRay Video
File size : 19.2 GiB
Duration : 1h 50mn
Overall bit rate : 24.8 Mbps
Maximum Overall bit rate : 48.0 Mbps

Video
ID : 4113 (0x1011)
Menu ID : 1 (0x1)
Format : MPEG Video
Format version : Version 2
Format profile : Main@High
Format settings, Matrix : Default
Duration : 1h 50mn
Bit rate mode : Constant
Bit rate : 22.1 Mbps
Nominal bit rate : 40.0 Mbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16/9
Frame rate : 23.976 fps
Colorimetry : 4:2:0
Scan type : Progressive
Bits/(Pixel*Frame) : 0.805

Audio #1
ID : 4352 (0x1100)
Menu ID : 1 (0x1)
Format : AC-3
Format/Info : Audio Coding 3
Duration : 1h 50mn
Bit rate mode : Constant
Bit rate : 640 Kbps
Channel(s) : 6 channels
Channel positions : Front: L C R, Rear: L R, LFE
Sampling rate : 48.0 KHz

to dxva-hd-hq(options taked from Megui)-video-h264-audio-ac3 (copy). file with next parameters:

bitr=5000
resolin=1920x1020

ffmpeg -i $orig -pix_fmt yuv420p -f rawvideo - | /usr/local/bin/x264 -o $outf - $resolin \
--pass 1 --bitrate $bitr --stats $logf --level 4.1 --ref 4 --mixed-refs --bframes 3 --b-adapt 2 --weightb --direct auto --filter -1:-1 --subme 7 \
--trellis 2 --partitions p8x8,b8x8,i4x4,i8x8 --8x8dct --vbv-bufsize 50000 --vbv-maxrate 50000 --me umh --threads auto --progress --no-psnr \
--no-ssim
sleep 2

echo "Second pass..."
ffmpeg -i $orig -pix_fmt yuv420p -f rawvideo - | /usr/local/bin/x264 - -o $outf $resolin \
--pass 2 --bitrate $bitr --stats $logf --level 4.1 --ref 4 --mixed-refs --bframes 3 --b-adapt 2 --weightb --direct auto --filter -1:-1 --subme 7 \
--trellis 2 --partitions p8x8,b8x8,i4x4,i8x8 --8x8dct --vbv-bufsize 50000 --vbv-maxrate 50000 --me umh --threads auto --progress --no-psnr \
--no-ssim

to play final rip on Windows with hardw.acceleration. Samples from source file (duration ~ 1min) encoded with this options, play with hard.accel. on MPC HC and PowerDVD, so it's ok.

But encoding process of full source take a very long time. What's wrong? Maybe need to cut some options in first pass? Or change all script?

For example, encoding this file on Megui with bitrate=1000 and the same preset and audio copy take about 4 hours

nm
23rd October 2008, 13:52
But encoding process of full source take a very long time. What's wrong?
Exactly how long is that (compared to MeGUI)?
Are both cores fully loaded while you are encoding?

Maybe need to cut some options in first pass?
Yes, or just use CRF encoding mode instead of two passes if you don't need to limit the output to a specific size.

yeye69
23rd October 2008, 14:45
Exactly how long is that (compared to MeGUI)?
Are both cores fully loaded while you are encoding?

Yes, or just use CRF encoding mode instead of two passes if you don't need to limit the output to a specific size.

First pass taked ~ 17 hours (fps 2.43), second still in process (seems slightly faster, 3fps):). Both cores are fully loaded almost all time. Megui (on Windows) spent ~ 4 hours, but bitrate was 1000 (on Linux, the difference in time between bitrates 1000 and 5000 was ~ 2), so, probably it will take ~ 8 hours.

Yes, I don't need to limit the final file size, but if I will use CRF it will compatible with DXVA decoding and will not cause a quality reduction?

And please, post your options with CRF, I will try to encode the samples and play on DXVA-players (MPC HC and PowerDVD) :thanks:

nm
23rd October 2008, 15:34
First pass taked ~ 17 hours (fps 2.43), second still in process (seems slightly faster, 3fps):). Both cores are fully loaded almost all time. Megui (on Windows) spent ~ 4 hours, but bitrate was 1000 (on Linux, the difference in time between bitrates 1000 and 5000 was ~ 2), so, probably it will take ~ 8 hours.
Ok, sounds like you have compiled x264 without Yasm. Install Yasm 0.7.2, configure x264 again and check that it gets built with assembly optimizations.

For extra speed, install a 64-bit distro if you don't have one already. :)

Yes, I don't need to limit the final file size, but if I will use CRF it will compatible with DXVA decoding and will not cause a quality reduction?
It should work fine.

And please, post your options with CRF, I will try to encode the samples and play on DXVA-players (MPC HC and PowerDVD) :thanks:
Replace "--pass 1 --bitrate x" by "--crf 22" (for example, use a value that you find suitable) and drop the second pass.