View Full Version : Mencoder and b-adapt 2
dyscoria
7th December 2008, 23:54
The current mencoder (from svn) allows the command line option: b_adapt=[on/off]
Does anyone know whether this uses the old or the new b_adapt (--b-adapt=2) algorithm?
Thanks!
LoRd_MuldeR
8th December 2008, 00:06
Encode a video, look at the information in the output file and you'll now ;)
dyscoria
8th December 2008, 00:09
Will do!
froggy1
8th December 2008, 00:14
The current mencoder (from svn) allows the command line option: b_adapt=[on/off]
Does anyone know whether this uses the old or the new b_adapt (--b-adapt=2) algorithm?
Thanks!
mencoder does not allow or disallow anything in regards to h264. mencoder parses the options of the libx264 library thus whenever a new option gets introduced in x264, it will be directly picked up by mencoder. In regards to b_adapt, you can choose to use b_adapt=1 (old), b_adapt=2 (new) nob_adapt (disable) or b_adapt=0 (disable)
dyscoria
8th December 2008, 13:55
Encode a video, look at the information in the output file and you'll now ;)
Not entirely sure how to find said information. Tried log=3 during the encode. Tried mplayer -identify on the output file.
mencoder does not allow or disallow anything in regards to h264. mencoder parses the options of the libx264 library thus whenever a new option gets introduced in x264, it will be directly picked up by mencoder. In regards to b_adapt, you can choose to use b_adapt=1 (old), b_adapt=2 (new) nob_adapt (disable) or b_adapt=0 (disable)
Erm as far as I'm aware from the mencoder man page, the only b_adapt possible options are "b_adapt" and "nob_adapt". No errors are given though when passing the option b_adapt=2 so i'm not sure whether its actually working, but guess i'll take your word for it. Guess I can look later at FPS during encode.
nm
8th December 2008, 14:08
Not entirely sure how to find said information. Tried log=3 during the encode. Tried mplayer -identify on the output file.
strings -50 videofile
Erm as far as I'm aware from the mencoder man page, the only b_adapt possible options are "b_adapt" and "nob_adapt".
As froggy1 explained, MEncoder's manual does not describe all possible values. See "x264 --longhelp" for more information and read the x264 source code for the whole truth ;)
No errors are given though when passing the option b_adapt=2 so i'm not sure whether its actually working, but guess i'll take your word for it. Guess I can look later at FPS during encode.
Just check the output file with strings or a hex editor.
LoRd_MuldeR
8th December 2008, 14:15
Not entirely sure how to find said information. Tried log=3 during the encode. Tried mplayer -identify on the output file.
Open the output file in Avinaptic (http://www.videohelp.com/tools/avinaptic) to get a full list of all x264 options that were used.
dyscoria
8th December 2008, 14:20
Awesome. Thanks for the help everyone :)
liquidator87
12th December 2009, 22:42
apparently b_adapt=2 is not working... The file is still encoded with b_adapt=1
LoRd_MuldeR
12th December 2009, 23:02
apparently b_adapt=2 is not working... The file is still encoded with b_adapt=1
With what tool and what version and with what command-line? If MEncoder or FFmpeg is failing, simply use the x264 CLI encoder ;)
Remember: If required, you can pipe from MEncoder/FFmpeg to the x264 CLI.
froggy1
13th December 2009, 02:14
apparently b_adapt=2 is not working... The file is still encoded with b_adapt=1
I've just encoded a small sample directly with mencoder.... here's what strings test.avi | grep x264 gives
x264 - core 80 r1373 4322f63 - H.264/MPEG-4 AVC codec - Copyleft 2003-2009 - 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.0:0.0 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 mbaff=0 constrained_intra=0 bframes=3 b_pyramid=0 b_adapt=2 b_bias=0 direct=1 wpredb=1 wpredp=2 keyint=250 keyint_min=25 scenecut=40 rc_lookahead=40 rc=crf mbtree=1 crf=20.0 qcomp=0.60 qpmin=10 qpmax=51 qpstep=4 ip_ratio=1.40 aq=1:1.00
LoRd_MuldeR
13th December 2009, 02:16
He probably used an old/broken build of MEncoder. If he got it from the package repository, he should make a fresh build from up-to-date sources himself...
liquidator87
13th December 2009, 11:36
@LoRd_MuldeR: you can talk directly to me :)... I use a svn build...
@froggy1: what command line switch do you use? I've simply added b_adapt=2 to the x264encopts string...
nm
13th December 2009, 12:59
@LoRd_MuldeR: you can talk directly to me :)... I use a svn build...
And what is your libx264 version? Show us the output from:
strings -50 videofile
or read the information with some other tool, such as Avinaptic.
@froggy1: what command line switch do you use? I've simply added b_adapt=2 to the x264encopts string...
That should work.
liquidator87
13th December 2009, 13:12
x264 - core 80 r1373 4322f63 - H.264/MPEG-4 AVC codec - Copyleft 2003-2009 - http://www.videolan.org/x264.html - options: cabac=1 ref=4 deblock=1:0:0 analyse=0x3:0x133 me=umh subme=8 psy=1 psy_rd=1.0:0.0 mixed_ref=1 me_range=16 chroma_me=1 trellis=2 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=-2 threads=3 sliced_threads=0 nr=0 decimate=1 mbaff=0 constrained_intra=0 bframes=3 b_pyramid=0 b_adapt=1 b_bias=0 direct=3 wpredb=1 wpredp=2 keyint=250 keyint_min=25 scenecut=40 rc_lookahead=40 rc=2pass mbtree=1 bitrate=10030 ratetol=1.0 qcomp=0.60 qpmin=10 qpmax=51 qpstep=4 cplxblur=20.0 qblur=0.5 ip_ratio=1.40 aq=1:1.00
Maybe b_adapt=2 depends on an option I've not set (in the second or maybe in the first pass)?
nm
13th December 2009, 13:18
x264 - core 80 r1373 4322f63 - H.264/MPEG-4 AVC codec - Copyleft 2003-2009
Ok, that should be fine.
Maybe b_adapt=2 depends on an option I've not set?
No, I don't think so. Post your complete MEncoder command-line.
liquidator87
13th December 2009, 13:23
1st pass:
profile: x264encopts=pass=1:level_idc=41:direct_pred=auto:b_pyramid=normal:subme=2:trellis=0:partitions=none:me=dia:no_8x8dct
cmd: mencoder video.m2ts -o video.h264 -profile pass1 -x264encopts bitrate=10030:frameref=4 -vf crop=1920:1040:0:20
2nd pass:
profile: x264encopts=pass=2:level_idc=41:direct_pred=auto:b_pyramid=normal:subme=8:trellis=2:partitions=all:me=umh:b_adapt=2:ssim:nofast_pskip
cmd: mencoder video.m2ts -o video.h264 -profile pass2 -x264encopts bitrate=10030:frameref=4 -vf crop=1920:1040:0:20
LoRd_MuldeR
13th December 2009, 14:55
What does "profile" (as opposed to "cmd") mean?
I can see "b_adapt=2" in the profile line, but it doesn't exist in the actual cmd line. So did you explicitly pass that parameter to MEncoder or not?
If "cmd" represents your command-line to call MEncder, then it seems you didn't...
liquidator87
13th December 2009, 15:01
"-profile pass1" means mencoder will also use the option specified by the profile named "pass1", which is the one I posted.
http://www.mplayerhq.hu/DOCS/man/en/mplayer.1.html#PROFILES
So it should be passed to mencoder, in fact all other parameters specified by the profile are correct
LoRd_MuldeR
13th December 2009, 17:57
Well, if you don't rely on the profile (for H.264 "profiles" have a different meaning anyway), but specify the parameter explicitly, what does happen?
liquidator87
13th December 2009, 19:09
the same result... b_adapt=1
@froggy1: can you post the command line and the parameters you've used for that result?
nm
14th December 2009, 01:05
1st pass:
profile: x264encopts=pass=1:level_idc=41:direct_pred=auto:b_pyramid=normal:subme=2:trellis=0:partitions=none:me=dia:no_8x8dct
cmd: mencoder video.m2ts -o video.h264 -profile pass1 -x264encopts bitrate=10030:frameref=4 -vf crop=1920:1040:0:20
b_adapt=2 must be set in the first pass because that's where frametype decision is done!
Read the commit message for reference: http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=9818865c1f5eccbc04fb51f062cb1b3abff02db0
This patch also reads b_adapt and scenecut settings from the first pass so that the x264 header information in the output file will have correct information (since frametype decision is only done on the first pass).
LoRd_MuldeR
14th December 2009, 01:15
Good point, nm :D
liquidator87
14th December 2009, 10:26
This means I can't use the default "turbo" mode on first pass if I want to use b_adapt=2 on second pass?
LoRd_MuldeR
14th December 2009, 12:30
"Turbo mode" isn't related to the issue. The "Turbo mode" is always enabled for the first pass of a 2-Pass encode, unless you explicitly pass the "--slow-firstpass" parameter (or MEncoder's equivalent).
Also the "Turbo Mode" only lowers settings that have zero (or near zero) effect on the final encode. It certainly doesn't mess with your "--b-adapt" setting, as that clearly does effect your final encode ;)
Here's the code in question:
/* Set faster options in case of turbo firstpass. */
if( b_turbo && b_pass1 )
{
param->i_frame_reference = 1;
param->analyse.b_transform_8x8 = 0;
param->analyse.inter = 0;
param->analyse.i_me_method = X264_ME_DIA;
param->analyse.i_subpel_refine = X264_MIN( 2, param->analyse.i_subpel_refine );
param->analyse.i_trellis = 0;
}
(Excerpt from x264.c (http://git.videolan.org/gitweb.cgi?p=x264.git;a=blob;f=x264.c))
liquidator87
14th December 2009, 12:53
You didn't get my point... or I didn't express myself :)
I've to add b_adapt=2 to the first pass, if I want to use it in the second pass... my mistake was that I thought the "turbo" settings specified in this post (http://forum.doom9.org/showpost.php?p=1301866&postcount=1) were the only one used in the first pass, but they are actually ADDED to the ones I specify (eventually overriding some)... so b_adapt=2 remains...
LoRd_MuldeR
14th December 2009, 12:54
Turbo Mode doesn't have anything to with whether b_adapt=2 is used or not. So I can't see how it should be related :confused:
You say that "if I use turbo mode (which is default), it is implicit that b_adapt=2 isn't used", but that is incorrect. The correct sentence would be:
"If I don't explicitly specify b_adapt=2 for the first pass, it is implicit that b_adapt=2 isn't used during the second/final pass."
liquidator87
14th December 2009, 13:05
I've edited my previous post... now everything is clear :)
LoRd_MuldeR
14th December 2009, 13:45
...but they are actually ADDED to the ones I specify (eventually overriding some)... so b_adapt=2 remains...
Yes, exactly :)
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.