View Full Version : Does x264 1-pass settings influence the final quality ?
Sasovics
5th March 2008, 04:46
Hey Folks,
I was wondering if x264 1st-pass settings influence the final quality.
Please look at the settings I usually use encoding my HD material below (especially the 1st-pass) and comment:
x264 --pass 1 --bitrate 6000 --stats ".stats" --bframes 3 --b-pyramid --direct auto --deblock -2:-1 --subme 1 --analyse none --me dia --threads auto --thread-input --cqmfile "prestige.cfg" --deadzone-inter 8 --deadzone-intra 4 --progress --no-psnr --no-ssim -o NUL %1
x264 --pass 2 --bitrate 6000 --stats ".stats" --ref 5 --mixed-refs --no-fast-pskip --bframes 3 --b-pyramid --b-rdo --bime --weightb --direct auto --deblock -2:-1 --subme 7 --analyse p8x8,b8x8,i4x4,i8x8 --8x8dct --trellis 0 --aq-strength 0.5 --aq-sensitivity 12 --deadzone-inter 8 --deadzone-intra 4 --me umh --threads auto --thread-input --cqmfile "prestige.cfg" --progress --no-psnr --no-ssim --output VIDEO.MKV %1
x264 --pass 1 --bitrate 6000 --stats ".stats" --bframes 3 --b-pyramid --direct spatial --deblock -3:-2 --subme 1 --analyse none --me dia --threads auto --thread-input --cqmfile "eqm_avc_hr.cfg" --progress --no-psnr --no-ssim -o NUL %1
x264 --pass 2 --bitrate 6000 --stats ".stats" --ref 5 --mixed-refs --no-fast-pskip --bframes 3 --b-pyramid --b-rdo --bime --weightb --direct spatial --deblock -3:-2 --subme 6 --analyse all --8x8dct --trellis 1 --me umh --threads auto --thread-input --cqmfile "eqm_avc_hr.cfg" --progress --no-psnr --no-ssim --output VIDEO.MKV %1
x264 --pass 1 --bitrate 6000 --stats ".stats" --bframes 3 --b-pyramid --direct spatial --deblock -0:-0 --subme 1 --analyse none --me dia --threads auto --thread-input --progress --no-psnr --no-ssim -o NUL %1
x264 --pass 2 --bitrate 6000 --stats ".stats" --ref 5 --mixed-refs --no-fast-pskip --bframes 3 --b-pyramid --b-rdo --bime --weightb --direct spatial --deblock -0:-0 --subme 7 --analyse p8x8,b8x8,i4x4,i8x8 --8x8dct --trellis 1 --me umh --threads auto --thread-input --progress --no-psnr --no-ssim --output VIDEO.MKV %1
Note, I am aiming for ultimate quality with the least detail loss, and least blocking. Gurus, please advise what options would you change, what should be added/removed from the cmdline setting above... ;)
Dark Shikari
5th March 2008, 04:50
Raising subme to 2 or 3 can help slightly on first pass, but that's about it.
cogman
5th March 2008, 05:24
Are you aiming for a given file size? (as a bitrate of 6000 seems a bit odd to me). If not, then ultimate quality and minimum bitrate is best achieved with a single pass crf mode. x264 has a very advanced single pass rate control and can give some pretty good results at a set crf value.
If you are targeting some media (IE HD -> DVD) then two pass is the way to go, but if you are targeting quality with little concern for end filesize (within reason of course) then a single pass CRF mode is the way to go.
Other then that, what Dark Shikari said, second pass is really where all the action is at (and for the most part you want your first and second pass to be as close as possible)
Sasovics
5th March 2008, 06:19
Yes, besides the quality I am aiming for a specific file size too.
Usually I do not touch the audio, so if I have a movie longer then 1:30 hour and has a DTS audio at 1540kbps I am aiming for 6-7 gigs.
If that is the case, my bitrate calculator gives me an avg bitrate of 5800 - 6000kbps for the video itself.
When the movie is 1:30 hour or less and has AC3 audio let's say at 480kbps I try to get it to 4.7GB DVD. In that case I have to lower my bitrate even below 5000kbps.
I'd be pretty interested in some CRF based single pass cmdline settings... Can you please post some HQ cmdline examples both for grainy real-life and non-grainy anime sources ? Definitely I'd give a shot to try them out ... Thanks in advance.
Any other comments guys ? ;)
Sasovics
7th March 2008, 01:06
Boyz,
What do you think about raising the "subme" value to 6-7 in 1st-pass ? Will it make a difference in the final quality ?
Dark Shikari
7th March 2008, 01:09
Boyz,
What do you think about raising the "subme" value to 6-7 in 1st-pass ? Will it make a difference in the final quality ?No, the effect is basically zero, and for all intents and purposes has an equal probability of lowering the quality by a minuscule amount, since the effect won't even be statistically significant.
cogman
7th March 2008, 03:42
Yes, besides the quality I am aiming for a specific file size too.
Usually I do not touch the audio, so if I have a movie longer then 1:30 hour and has a DTS audio at 1540kbps I am aiming for 6-7 gigs.
If that is the case, my bitrate calculator gives me an avg bitrate of 5800 - 6000kbps for the video itself.
When the movie is 1:30 hour or less and has AC3 audio let's say at 480kbps I try to get it to 4.7GB DVD. In that case I have to lower my bitrate even below 5000kbps.
I'd be pretty interested in some CRF based single pass cmdline settings... Can you please post some HQ cmdline examples both for grainy real-life and non-grainy anime sources ? Definitely I'd give a shot to try them out ... Thanks in advance.
Any other comments guys ? ;)
Woops, kind of left you there :).
Basically a good HQ crf pass will look like your HQ second pass, only instead of --bitrate 6000 you will have crf 20.0 (or so). After that, it is just changing the CRF value to what looks pleasing too you (without loosing too much quality). For most people, 18 is near perfect. For me, 20-21 look pretty dang good. Others have a tolerance for up to 24.
Nikos
8th March 2008, 20:19
Is there a clear answer, which 1-pass settings does not influence negative in the 2-pass quality.
Sasovics
10th March 2008, 01:58
You can use any of my 1-pass settings in the first post of this thread, eventuelly you can raise "subme" to 3. That's what I did in my latest encodes... It helped me to improve a quality a bit ;)
Nikos
10th March 2008, 04:17
Thanks Sasovics but i want which 1-pass settings does not influence negative the quality in the 2-pass encoding.
I want answers like:
The x setting does not influence negative.
The y setting influence a little negative.
The z setting influence very negative.
Now i use identical settings in both passes.
Sasovics
10th March 2008, 05:39
Usually I use these 3 profiles for HD material and switch between them depending on the source.
For all encodes I did, I can say, I got best results using settings "x" (as you named it), however sometimes I switch between the Prestige and Sharktooth's eqm matrix.
Nikos
10th March 2008, 19:47
I don't want profiles or best settings :)
To be more clear, i want something like this:
The --weightb parameter does not have any negative influence if i omit in the first pass?
The --bime parameter does not have any negative influence if i omit in the first pass?
Irakli
10th March 2008, 20:54
I don't want profiles or best settings :)
To be more clear, i want something like this:
The --weightb parameter does not have any negative influence if i omit in the first pass?
The --bime parameter does not have any negative influence if i omit in the first pass?
Hi, Nikos!
1) --bframes, --keyint, --min-keyint, and --b-pyramid must be the same for both 1st and 2nd pass, according to this post by DS (http://forum.doom9.org/showthread.php?p=1099576#post1099576). Otherwise, quality will be lowered.
2) --subme below 3 in 1st pass will result in a slight loss of quality; however, higher than 3 in 1st pass is pretty much useless for higher final quality (according to the posts above).
3) All other options can be lowered in 1st pass without perceptible negative quality impact.
Regards,
Irakli
Dark Shikari
10th March 2008, 21:03
Hi, Nikos!
1) --bframes, --keyint, --min-keyint, and --b-pyramid must be the same for both 1st and 2nd pass, according to this post by DS (http://forum.doom9.org/showthread.php?p=1099576#post1099576). Otherwise, quality will be lowered.The first three must be the same or it won't even work.
Also note AQ strength should be the same in both passes.
Sasovics
10th March 2008, 21:20
Good point Dark Shikari!
I've just noticed that I am not including --aq-strength & sensitivity in my 1st-pass cmdlines above! This could be also the reason why I have excessive blocking especially in real dark areas!
Thanks for taking this to my attention! :)
Nikos
10th March 2008, 22:09
Thanks Irakli and Dark Shikari for the reply.
Most people don't know the right 1-pass settings and simply guess :)
I get opinions only from experienced users :rolleyes:
talen9
11th March 2008, 00:09
Good point Dark Shikari!
I've just noticed that I am not including --aq-strength & sensitivity in my 1st-pass cmdlines above! This could be also the reason why I have excessive blocking especially in real dark areas!
Thanks for taking this to my attention! :)
Well, if you have an x264 build with VAQ compiled in (such as the one which auto-updates with MeGUI) and you *don't* specify anything, you're already using it with the default values of aq-strength=0.5 and aq-sensitivity=13 :)
gav1577
11th March 2008, 03:58
The first three must be the same or it won't even work.
Also note AQ strength should be the same in both passes.
Will automated two pass work for aq with or without turbo checked ? :)
ImmortAlex
16th March 2008, 09:34
I'm trying to make Irakli's frase "All other options can be lowered in 1st pass" a little bit clearer:
1) --ref: is it correct to specify --ref 1, or should I allow more references (2 or 3)?
2) --deblock: should I specify same alpha and betta, or may be --no-deblock for 1st pass is good?
3) --zones: should I specify --zones in 1st pass or it has effect only in 2nd?
4) --partitions: can I switch off some of them, or may be even --partitions none is correct?
5) --8x8dct: can I switch it off? Is it correct, when 1st pass will encode in Main Profile, but 2dn pass - High Profile?
6) --me: is --me dia enough? And AFAIR --merange doesn't matter for dia and hex?
7) --no-chroma-me: can I specify this switch for speed?
8) --no-cabac: can I switch CABAC off?
Manao
16th March 2008, 10:35
1) you can lower --ref
2) you could use --no-deblock, but the speed gain isn't worth it
4) you can switch off partitions
5) you can switch off 8x8dct
6) you can use --me dia
7) you should be able to use --no-chroma-me (though for that one, I'd better test it)
8) you could switch off cabac, but the speed gain isn't worth it
Keep in mind that the bigger the difference between first and second pass settings, the lower the quality of the second pass (though the degradation of quality should be small). So there's a moment when it makes no sense trying to speed up first pass even more. When first pass is 4 times as fast as the second, increasing it's speed by 100% will only shave off 10% of the overall encoding time, while the impact on quality may become visible.
Nikos
16th March 2008, 13:11
Thanks Manao for the clear answer!!!
What about for:
1. --subme
2. --nofastskip
3. --weightb
4. --b-rdo
5. --bime
6. --no-dct-decimate
7. --mixed-refs
8. --no-b-adapt
Manao
16th March 2008, 13:30
--weightb should be left on (almost no impact on speed)
--no-b-adapt should never be used.
--no-dct-decimate should remain the same between both passes, and has no impact on speed.
The remaining options can be changed / disabled, but the same remark apply : the bigger the difference between passes, the more harmfull to quality the speed boost will be.
Nikos
16th March 2008, 19:32
Thanks again Manao for the crystal clear answer.
ImmortAlex
17th March 2008, 04:31
Thanks, Manao! Especially for comment about --me, partitions and 8x8dct, I hope it will speed up my encodings more :)
And also about cabac: AFAIK switching it on and off almost equal to rising and lowering bitrate at some moderate level. And because of 1st pass bitrate can be not equal to 2nd pass, I hope it will not harm quality. But I've heard that cabac eat a lot of processing power... Hmmm, I need more tesings :) My CPU is quiet old now, not so powerful like Core2Quad.
About lowering reference frames: I'm using --ref 3 for 1st and 2nd pass. Some time ago I used --ref 5, but final statistic about encoding clearly shows me that anything more than --ref 3 is almost useless for "normal" movies. Also it shows me that third reference frame is used in more than 10% cases often. So question is: which setting is adequate for 1st pass if I use --ref 3 for 2nd pass?
PS: things was so simple in time of XviD encodings...
Dark Shikari
17th March 2008, 04:33
But I've heard that cabac eat a lot of processing power... CABAC is not particularly much slower than CAVLC... most of the other settings are more important...PS: things was so simple in time of XviD encodings...Not really, Xvid just did what we told you to do in the first place--cut all the settings to very low ones. Its just that x264 allows you to do otherwise, so people become silly and do things like post threads like these... ;)
ImmortAlex
17th March 2008, 07:50
Not really, Xvid just did what we told you to do in the first place--cut all the settings to very low ones.
It was a joke :) And XviD has less parameters, and there is a thread with clearly defined presets...
CABAC is not particularly much slower than CAVLC... most of the other settings are more important...
The question is... hmmm... does switching CABAC off in 1st pass affects quality in 2nd pass at all? Mathematically spkeaking: is CABAC compression linearly better than CALVC, or it some times compress better and some times - much better, affecting... (my bad english...) form if bitrate curve? Or, maybe, I understand everything wrong :)
akupenguin
17th March 2008, 09:31
The difference between CABAC and CAVLC is certainly not a constant (graph (http://akuvian.org/src/x264/entropy_mpegcif.png)), but I don't know if it's linear enough within one video.
ImmortAlex
18th March 2008, 11:37
OK, I will not change CABAC settings between passes since this graph is awful.
So, now my 1st-pass settings are:
--pass 1 --bitrate NNNN --partitions none --bframes 3 --b-pyramid --ref 2 --weightb --me dia --subme 3
Still not realtime for 720x480 @23.976 on my Prescott 3.0GHz, but near to it.
2nd pass setting are something like HQ-Slower in MeGUI.
I'm notice that Manao doesn't answer about zones :)
And also I found one more questionable option: --direct :) Currently I use default value ("spatial") for 1st pass and "auto" for second.
Manao
18th March 2008, 12:12
I didn't answer about zones because if you wanted to use them, you'd know what they are for, and you'd then know the answer to the question.
Dark Shikari
18th March 2008, 15:05
And also I found one more questionable option: --direct :) Currently I use default value ("spatial") for 1st pass and "auto" for second.No, no, no, no, no. If you don't use auto on the first pass, and you use auto on the second, the second pass won't have any data from the first pass to use, and it'll default to temporal, reducing quality.
ImmortAlex
19th March 2008, 10:56
No, no, no, no, no
:thanks:
But, wait!
Just looking for results: 1st pass done with default --direct ("spatial" according to --help output), 2nd pass done with --direct auto, and output is:
x264 [info]: direct mvs spatial:0.0% temporal:100.0%
Am I missing something or is it a bug?
I didn't answer about zones because if you wanted to use them, you'd know what they are for, and you'd then know the answer to the question.
I'm using it just for saving bits in final titles (q=0.1 typically). And I'm having some doubt... I don't have clear understanding how ratecontrol works, only basic ideas, and I with my little knowledge I can easily imagine that it lowers quality in 1st pass according my zone settings and than lowers quality in 2nd pass even more.
Basically, you are right, I must do more testings myself :)
Sasovics
21st March 2008, 23:59
This is a very useful thread! Ppl can learn a lot from it, especially how to set up their 1st-pass which is IMHO not that well documented as profiles for 2nd-pass.
Thanks to all who has contributed. ;)
Ranguvar
22nd March 2008, 00:41
:thanks:
But, wait!
Just looking for results: 1st pass done with default --direct ("spatial" according to --help output), 2nd pass done with --direct auto, and output is:
x264 [info]: direct mvs spatial:0.0% temporal:100.0%
Am I missing something or is it a bug?
Re-read what D_S said...
On the second pass, x264 will look for data from the first pass to decide where to use temporal and where to use spatial... however, there is no data. You set 1st pass to spatial, not auto, which would have saved such data. So, it will default to temporal.
bond
22nd March 2008, 11:43
does it harm to disable trellis during the first pass?
Dark Shikari
22nd March 2008, 14:01
does it harm to disable trellis during the first pass?no...
Sasovics
22nd March 2008, 20:43
Does it help (or has no effect at all) to raise --ref to 3 in the first pass ? Default (if not used in the cmdfile) is 1
Dark Shikari
22nd March 2008, 21:19
Does it help (or has no effect at all) to raise --ref to 3 in the first pass ? Default (if not used in the cmdfile) is 1probably not
Sasovics
22nd March 2008, 21:22
Anyway .. I'll test and let you know guys... ;)
EDIT: however I've noticed a slight improvements in my encodings when using --weightb on both passes. (I was using it only in the 2nd-pass so far)
ImmortAlex
24th March 2008, 08:24
As Manao said:
--weightb should be left on (almost no impact on speed)
So I turn it on too :)
cakuhnen
24th March 2008, 22:16
This are the first pass Fast mode in Sonic Cinevision AVC
FIRST PASS FAST MODE
-----------------------------------------------------------------------
Encode Phase: Preparing... Fri Mar 21 19:39:37 2008
-----------------------------------------------------------------------
TLPlayer Thread started
Encoding to output file: C:\Documents and Settings\Administrator\My Documents\CineVision Encodes\FVSJ.b264
Encoder Setup:
profile_id: H264PROFILE_HIGH
level_id: 32
idr_interval: 15
reordering_delay (P-distance): 3
use_b_slices: true
interlace_mode: H264_PROGRESSIVE
frame_mbs_mode: H264_FRAME_MBS_ON
def_horizontal_size (width): 720
def_vertical_size (height): 576
frame_rate: 25
num_reference_frames: 2
rd_optimization: false
max_l0_active (P Slice Prediction List): 0
max_l1_active (B Slice Prediction List): 0
bit_rate_mode: H264_VBR
bit_rate_buffer_size (bits):7503872
bit_rate: 3000000
max_bit_rate: 8000000
quant_pI: 0
quant_pP: 0
quant_pB: 0
max_quant: 51
inter_search_shape: 16x16
entropy_coding_mode: H264_CAVLC
use_hadamard_transform: false
sar_width: 16
sar_height: 11
video_format: PAL
video_full_range: N/A
num_units_in_tick: 1080000
time_scale: 27000000
vbv_buffer_units: H264_VBV_Units_Time
vbv_buffer_fullness (initial): 84419
vbv_buffer_fullness_trg (target): 0
use_deblocking_filter: false
deblocking_alphaC0_offset: -1
deblocking_beta_offset: -1
video_type: H264_HD_DVD
video_pulldown_flag: VIDEO_PULLDOWN_NONE
stream_type: H264_STREAM_TYPE_II
write_au_delimiters: true
write_seq_end_code: true
write_timestamps: true
timestamp_offset (frames): 89950
drop_frame_timecode: false
vcsd_mode (scene detection): VCSD_MODE_IDR
vcsd_sensibility (scene detection sensitivity): 50
slice_mode (use multiple slices per picture): true
slice_arg (# of slices per picture): 1
b_slice_reference: false
b_slice_pyramid: false
cb_offset: 1
cr_offset: 1
me_subpel_mode: H264_FULL_PEL
me_weighted_p_mode: 0
me_weighted_b_mode: 0
enable_fast_intra_decisions: false
enable_fast_inter_decisions: true
pic_ar_x: -1
pic_ar_x: -1
calc_quality (calculate PSNR): true
cpu_opt: H264_CPU_OPT_AUTO
num_threads: 0
min_idr_interval: 2
adaptive_b_frames: true
idr_frequency: 1
field_order: H264_TOPFIELD_FIRST
fast_multi_ref_me: false
fast_sub_block_me: false
allow_out_of_pic_mvs: true
enable_intra_big: true
enable_intra_8x8: true
enable_intra_4x4: true
enable_intra_pcm: false
enable_inter_big: true
enable_inter_8x8: true
enable_inter_4x4: true
enable_inter_pcm: false
fast_rd_optimization: 0
quant_mode: 2
adaptive_quant_brightness: 0
adaptive_quant_contrast: 0
adaptive_quant_complexity: 0
film_grain_mode: 1
black_norm_level: 0
grain_opt_strength: 0
I want to ask the developers of x264 if its possible to add timecode offset to the encoder, just in case u need your movie timecode different from 00:00:00:00
For example: Source PAL start 00:59:58:00
in Mainconcept i just add in timecode_offset 89950 and it encode my movie start from 00:59:58:00 not 00:00:00:00
Based on this settings can someone show me the required x264 command line options to do the same?
Thanks
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.