Log in

View Full Version : x264 enforce keyframe with chapterlist


gigah72
24th August 2007, 08:32
is there a way to force x264 encode to set a keyframe on a given chapterlist in OGG format, or whatever format?
the problems is, that there is often a hickup in the video when i jump chapters (in mp4 container).

Selur
24th August 2007, 10:44
afaik: no
So if there is a way I would like to know too. :)

Sharktooth
24th August 2007, 12:14
with xvid: get the chapter list, look at the chapter times, translate them into frame numbers, make zones starting at those frames forcing a keyframe at zone start...
there is a problem with x264... there's no way to tell x264 to force a keyframe

Selur
24th August 2007, 12:35
make zones starting at those frames forcing a keyframe at zone start...
How do you force a keyframe at the beginning of a zone?
(afaik zone normaly do not start with a keyframe)

gigah72
24th August 2007, 12:40
would it be difficult to implement such a function?
maybe an idea for next revision ... ?

Kurtnoise
24th August 2007, 13:03
Toff had made a patch (http://forum.doom9.org/showthread.php?p=740220#post740220) for that some times ago...

gigah72
24th August 2007, 13:42
this is good to know, thx for the info.
but i'm clueless to use it into 667b and the lack of support with adaptive bframes is also unsatisfying, at least to me.

Selur
24th August 2007, 14:35
Why didn't the path make it into 'standard' svn?

Kurtnoise
24th August 2007, 15:56
not good enough ?

Trahald
24th August 2007, 20:05
It just adds a few functions to 1 file.. as long as the parts of x264.c he modified to call the functions hasnt changed to much, it can be made into a standard .diff fairly easily

Sharktooth
24th August 2007, 20:08
i think there is no point in submitting an incomplete patch

SuperDuperDave
24th August 2007, 21:28
You could try encoding it in more than one piece, split on chapters, then use YAMB/MP4Box to splice them together. Since a video has to start with a keyframe, this should work.

Trahald
25th August 2007, 16:14
i got the x264.c file changes he made onto a clean checkout of x264.c from r671. gonna see if i can get it to work with b-adapt when i have time and then post a diff.

Kurtnoise
23rd September 2007, 09:10
i gonna see if i can get it to work with b-adapt when i have time and then post a diff.
any news on this ?


because US Open is obviously finished now...:p

nonoitall
26th October 2007, 08:58
(Sorry to be bumping a month-old thread.) I'm anxious to see this feature as well. Any progress? In any case, I know you have a life of your own and I'm not trying to bug you if you haven't found the time - I was just curious.

audyovydeo
26th October 2007, 11:03
How do you force a keyframe at the beginning of a zone? (afaik zone normaly do not start with a keyframe)


I remember your question back in July went unanswered :

http://forum.doom9.org/showthread.php?p=1025567#post1025567


But since the new options that can be used with zones include --scenecut ("8x8dct, b-bias, b-pyramid, bime, brdo, chrome-me, dct-decimate, deblock, direct, fast-pskip, me, merange, mixed-ref, nr, partitions, ref, scenecut, subme, trellis")

one could possibly define a zone sitting astride a chapter boundary and set scenecut very low. It's a workaround, of course. Untested, of course ...

cheers
audyovydeo

nonoitall
26th October 2007, 12:24
I gave that a try and no success so far. I made a 2-frame zone in the middle of one of my encodes and cranked up scenecut to 100 within the zone, but only succeeded in changing the previously P and b frames into P and P frames. I'm no expert on x264 though.

Without zones:
x264 --keyint 300 --bframes 3 --b-pyramid --pass 1 --bitrate 1000 -A all --direct auto
-w --subme 6 --b-rdo --mixed-refs --trellis 2 --progress --threads 2 --thread-input
-o output.mp4 input.avs

With zones:
x264 --keyint 300 --bframes 3 --b-pyramid --pass 1 --bitrate 1000 -A all --direct auto
-w --subme 6 --b-rdo --mixed-refs --trellis 2 --progress --threads 2 --thread-input
--zones 256,257,scenecut=100 -o output.mp4 input.avs

Does the zone need to be larger? Is there something else I should try changing? I tried putting the zone in a couple different spots to no avail. I was also hoping maybe the documentation was wrong about scenecut and tried changing it to 1, but that didn't work either.

audyovydeo
26th October 2007, 12:30
I gave that a try and no success so far. I made a 2-frame zone in the middle of one of my encodes and cranked up scenecut to 100 within the zone,

I think 2 frames is way too small. Try 20 or 25 frames before & after.

I repeat I havent tried this myself : I'd love to but I'm offsite.


audyovydeo

akupenguin
26th October 2007, 12:44
That generally won't work unless there really is a scenecut there, in which case it'll probably be a keyframe anyway. scenecut=100 doesn't force anything.

nonoitall
26th October 2007, 12:54
I'll give larger zones a try tomorrow, just for the heck of it. I can understand why there's probably no way to force it by this method when there isn't a big enough difference between frames though. How would one go about manually changing the stats file to insert keyframes?

akupenguin
26th October 2007, 13:53
Find the line that begins with "in:<framenumber>". Replace whatever type it has with "type:I".
If you change lots of frames this way it could throw off bitrate prediction, but just a few frames for chapters shouldn't have noticeable consequences.
Don't worry about B-frames and reordering, x264 will fix that for you.

nonoitall
26th October 2007, 22:22
Cool. I thought it would be more complicated than that.

EDIT: Just out of curiosity, how come 'in' frames in the stats file aren't in order and don't correspond to the ordered 'out' frames?

akupenguin
27th October 2007, 08:21
That's the B-frame reordering. "in" is the display order, "out" is the bitstream order. It doesn't actually matter what order the lines are in the stats file, x264 parses the whole file and assembles a list of all frames before doing anything to them. And the "out" numbers in the file are ignored and re-derived from the frame types.

nonoitall
27th October 2007, 11:40
Interesting. :) Thanks!

Trahald
27th October 2007, 18:35
any news on this ?


because US Open is obviously finished now...:p

Hehe.... RW been very busy. I looked for a while and really was overwelmed by x264's code. I looked at the qpfile code and it hooks into the same spot the above patch does. qpfile forces bframe adapt off (if i comment out bframeadapt = 0 qpfile doesnt work) i started parsing the code and got a headache. If i put it out as a patch im just going to do the same thing. force bframeadat = 0.