PDA

View Full Version : FFmpeg x264 Encoding Guide Link


Pookie
28th January 2007, 13:56
http://rob.opendot.cl/index.php/useful-stuff/ffmpeg-x264-encoding-guide/

Yong
28th January 2007, 18:05
There are some options are incorrect, or missing arguement:
-chroma 1 is chroma me? if yes, it should be -cmp chroma
-bidir_refine 1
-me umh, 8 seems to be ignored
-rc_eq 'blurCplx^(1-qComp)' give me "parser underflow", and ^ seems to be ignored while encoding.(is that windows cmd.exe to blame?)

and some important options:
-deblockalpha, -deblockbeta, -directpred and -b_strategy

8x8dct still doesnt work:angry:
btw, thx for the guide:D

Sirber
28th January 2007, 18:11
cool guide! thanks!

Schrade
29th January 2007, 21:03
http://rob.opendot.cl/index.php/useful-stuff/ffmpeg-x264-encoding-guide/

Nice guide! I can't wait to see your PSP guide finished. Don't forget to make settings for the new Dark_AleX custom firmware 3.03 OE-C! 480x272, 16384 Kbps max

superdump
29th January 2007, 22:32
Aaargh. Just lost my post trying to 'go advanced'. This re-type is going to be quick and dirty, sorry.

-chroma 1 should work but -cmp +chroma would be more consistent with my other options for -flags and -flags2.

-bidir_refine 1 is correct. Typo on my part.

I'm quite sure, looking at the code, that it should be -me_method 8 for current svn trunk FFmpeg.

I would blame cmd.exe for ^. Maybe some shells need that char escaping.

I generally don't alter the deblocking params but maybe the default for directpred is wrong. I'll check that. -b_strategy should be set to 1 if you're using more than 1 b-frame.

I'll post command lines here for custom firmwares if full listings of constraints are provided. Also, I would appreciate more information about the PSP constraints to complete that guide as I think my info is outdated.

Finally, the site and guide are mine. I'm glad the x264 interface in FFmpeg and guides on my site are appreciated.

Have fun. :)

akupenguin
29th January 2007, 23:13
-b_strategy should be set to 1 always. (though of course it doesn't matter if you aren't using B-frames at all)

Yong
29th January 2007, 23:28
Ok, i followed your guide, copy and paste it into a batch file,
here is the output from hexeditor:
http://img402.imageshack.us/img402/9431/clipboard01su1.png

as you can see, the "me" still "dia",
i changed it to -me umh and the output indeed changed to umh, SSIM value changed too;)

btw im using the "default" avi container, the x264 encoding info will be stripped if using mp4.

Pookie
30th January 2007, 01:53
Thanks for the kind words, but that site isn't mine. Just posted a link, as the ffmpeg syntax for h264 is a bit hard to find.

Edit: Ah, Superdump! Thanks for the info :)

celtic_druid
30th January 2007, 05:34
Yep, should be -me hex/umh/full. You could also use *.h264 for output to get a raw stream with encoding info present.

ScootyPuffJr
30th January 2007, 05:51
Superdump, could you post a link to the build of FFMPEG you are using? I've tried your command line options for iPod encoding and I get an unrecognized option error for '-flags'. I didn't see anything on your site/guide referencing the build.

Thanks!

superdump
30th January 2007, 19:09
ScootyPuffJr: I build FFmpeg myself using the svn trunk code.

celtic_druid: With current svn? As far as I can see, "me" isn't an option in libavcodec/utils.c but "me_method" is. And I defined ME_UMH as 8, so me_method 8 should work unless something's borked.

Yong: Did you use -me_method 8 for the final/only pass?

Yong
30th January 2007, 21:57
Yong: Did you use -me_method 8 for the final/only pass?

Yup, and -me_method 8 doesnt work, i have tried other options like full and hex, but same result, ffmpeg still using the default me for x264. its only work with xvid/ffmpeg internal codecs.

celtic_druid
30th January 2007, 22:23
In ffmpeg.c opt_motion_estimation (-me) sets me_method though.

Try yourself
-me umh vs. -me_method 8 with .h264 as output and have a look in a hex editor.

superdump
30th January 2007, 22:27
OK. I believe you. It seems strange but I'll change it. I suspect it's not intended behaviour but I'll look into it further if I can be bothered. ;) Editing the guides...

Yong
30th January 2007, 22:49
lol:)
its remind me about the old mplayer/mencoder docs:
"pls read the xyz.c for informations."

actually i dont use ffmpeg, it crash for me alot, im too noob to using it:p
untill recently i read the ffmpeg mailling lists and the source codes, to get the working xvid/x264/lavc encoding options.

Btw any idea why the partition "i8x8" doesnt work? as the option 8x8dct is already there,
mp4info report the ffmpeg encoded file is 5.1@main, hexeditor show the encoding info is analyse=0x1:0x131 as well.

superdump
1st February 2007, 01:33
-partitions +i4x4+i8x8+p8x8+b8x8 -flags2 +8x8dct doesn't enable 8x8dct? *sigh* It would be nice if the FFmpeg command line interface worked in some uniform way rather than having bits of code dotted about that override each other. (This comment is somewhat unrelated as there shouldn't be anything overriding this code anywhere... I'm just tired and whingey. ;))

quake74
2nd February 2007, 11:08
Thanks for all the good infos! Is there a way to set the level of a 264 encode with ffmpeg? I am asking because of of psp/ipod compatibility...

superdump
3rd February 2007, 01:48
quake74: If you look at the guides you'll notice an appropriate parameter.

Guys and gals, I just tried the command line (I've mainly been theorising and not testing these command lines) and the various flags don't seem to work for me. For example, -cmp chroma doesn't work properly (says it's NaN) but -chroma 1 does. Does anyone else experience this?

ilovejedd
3rd February 2007, 04:52
Does the -vlevel parameter still work? The latest build I downloaded from http://arrozcru.no-ip.org/ffmpeg_builds/ didn't have that option. I did a:
ffmpeg -h >> help.txt
and searched help.txt for 'level' but there wasn't such an option.

quake74
3rd February 2007, 13:18
Ok, in the latest build ffmpeg-r7760-win32.tar.gz going -vcodec h264 produces an error, but using ffmpeg-SVN-r7409-full-shared-w32threads.tar.bz2 works for me! (The parameter is -level and not -vlevel).

quake74
3rd February 2007, 15:04
I did some tests with my psp, and apparently you need -level 13 -bf 0 -refs 2. I tried upping to level 20 or 21 and using more than 1 bframes, but they all fail. And under windows, the -rc_eq 'blurCplx^(1-qComp)' can just be changes into "blurCplx^(1-qComp)" and it works. So here is the bat file which produces playable psp files for me


ffmpeg -i "%~f1" -vcodec h264 -crf 30 -level 13 -bf 0 -flags +loop -cmp +chroma -partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -flags2 +bpyramid+wpred+mixed_refs+8x8dct+brdo -me umh -subq 5 -trellis 2 -refs 2 -coder 1 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -rc_eq "blurCplx^(1-qComp)" -acodec aac -ab 64 -ar 48000 -s 320x240 "%~dpn1_psp.mp4"


Edit: Out of curiosity, if I use "-g 250" all the frames are grey until the first keyframe, so I removed it.

superdump
28th February 2007, 16:40
I think I discovered what was making the flags not work for me - I had been compiling with the -ffast-math CFLAG. I think this breaks -flags and similar options.

Selur
25th February 2008, 15:52
Are there builds out there that let one use Dark Shikaris adaptive quantization patch and nal-hrd inside ffmpeg?
Is it possible to use zones like with x264.exe?

bobsobol
5th May 2008, 16:54
IMS the ^ character was always on the list of reserved / special characters. DOS 3 manual used to list it along with < > | * ? % $ @. I would not write a command line (console build) program and expect any of these characters to reach my program unaltered by the OS... in fact, I would rather suspect that what my program would receive from the parameter list would terminate after any of the above characters. Except that environment variables enclosed in % symbols would be decoded if available.

In at least one MS OS I have used it represented a new line, enabling you to perform multiple commands from a single line without redirection. eg echo "line 1" ^ echo "line 2" would display:-line 1
line 2

The implementation of those reserved characters has changed on MS OS' several times however, as many may remember that it is not until NT 4 that named pipes started working at all, and redirected output and input have always been flaky. Particularly piping "|" directing input "<" and directing stderr "&>"

The correct code for "escape" sequences also changed several times over the life of DOS, the only way to achieve this consistently across DOS was to use an advanced text / hex editor to include the US/ASCII escape character in a batch file or program source code. Quite often however DOS would represent Esc as "^[" with the escaped code following, sometimes (but not always) closed with "]".

I know of no particular reason why any of this would be of interest to anyone here so I do not include (and have not researched) as much as I could. I quote from memory only because I have memory of such things where many do not.

NT based command lines are far more advanced and standardised than DOS. Hence I hate it when people talk about starting a DOS command in XP, there is no such thing unless you run emulation or a VM. However the NT command line is specifically designed to be backward compatible with classic DOS command lines and Batch files, so some legacy glitches have to be maintained.

Using alternative shells (bash fe) do not counter many of these limitation when the called program is built as a PE, as the method of parameter passing (received by function main() in a C program) are handled in the OS not the shell.

Using ELF files run under Cygwin may counter the issue however. The only other alternative I see (if the functionality is absolutely required) would be to include a search and replace function in Win32 builds which replaced some other sequence with "^" before further processing of received parameters.

J_Darnley
5th May 2008, 20:55
You need to escape ^ in the Windows Command shell as ^^ or enclose it in " as quake74 discovered.
And I quote from the WinXP Help & Support Center
'The characters <, >, |, &, ^ are special command shell characters and must be either preceded by the escape character (^) or enclosed in quotation marks when used in string (that is, "StringContaining&Symbol".'