View Full Version : Setting IDR frames in x264 for chapter start frames?
Heini011
20th December 2008, 23:55
Hi,
i'am currently switching from xvid to x264. (in the 2. encode with the new xvid 1.3 i encountered already the old "vhq for b-frames causes chrashes on sharp videos with some kind of caotic motion" bug again...).
but i can't find any information, how could i force keyframes (idr frames) for a fast chapter access at playback time. in xvid that is no problem within zone settings, but in x264 i can only configure different bitrates for zones. but what about chapter-points ?
greetings, Heini.
kemuri-_9
21st December 2008, 02:46
you can use the qpfile option to force frame types at frame #s and quantizers (if desired)
the qpfile option by default sets b-adapt to 0 and scenecut to -1;
this is from when the qpfile had to specify the entire video, and this setting remains for maintaining that way of functioning.
Edit
so just specify your desired scenecut and b-adapt after you specify the qpfile to have those values used.
/Edit
the qpfile is formatted fairly simply:
2000 I -1
9000 I -1
following a format:
frame_number frame_type frame_quantizer
frame_number is the frame number to set
frame_type is a character representing the type, I represents an IDR frame.
frame_quantizer is the quantizer to use, -1 is to let x264 specify (so you only set the type and not the quantizer)
the above example would force IDR frames at frames 2000 and 9000.
a worthy note is to have the frame_numbers in ascending order, or else the frames not specified in order won't get set.
Turtleggjp
27th December 2008, 21:51
I tried this, and it didn't seem to work (encode succeeded, but I-frames were not forced). Here is the command line I used:
"G:\Apps\x264.999.exe" --qpfile "G:\HDTV\Big Bang\Big Bang 211 Iframes.txt" --scenecut 30 --b-adapt 2 --level 4.1 --ref 4 --mixed-refs --bframes 5 --weightb --direct auto --subme 9 --trellis 0 --b-pyramid --partitions all --8x8dct --me umh --merange 12 --no-fast-pskip --crf 25.0 --threads auto --progress --sar 1:1 -o "G:\HDTV\Big Bang\Big Bang 211 progressive 999 (sub9 b-adapt2 5B Iframes CRF 25.0).mp4" "G:\HDTV\Big Bang\Big Bang 211 progressive.avs"
The qpfile contains this:
5234 I -1
14818 I -1
24712 I -1
Did I miss something? Thanks.
Matt
kemuri-_9
27th December 2008, 22:32
hmmm.... seems that re-enabling scenecut now discards frame types as declared in the qpfile
(qp values are kept, but not the frame decisions)
so if you can live without scenecut active, then just let it stay disabled.
laserfan
27th December 2008, 22:49
FWIW I've had good success opening my encoding with Avidemux and then selecting an appropriate I-frame, after-the-fact. If your scenecutting is working well (I just use --pre-scenecut, works fine) then the I-frames are where you need/want them to be.
Turtleggjp
27th December 2008, 23:33
FWIW I've had good success opening my encoding with Avidemux and then selecting an appropriate I-frame, after-the-fact. If your scenecutting is working well (I just use --pre-scenecut, works fine) then the I-frames are where you need/want them to be.
I'm not worried about where they land during most of the video. I was trying to do what the original poster was trying to do, and that was to put an IDR frame at the start of chapter points, to enable faster chapter seeking. I'm trying to put chapters at the edit points (usually completely black at the time) and I was able to modify my Excel spreadsheet that I use to figure out stuff like chapter times based on VirtualDub's edit points to figure out which frames should be forced as IDR frames.
So if I do not specify a scenecut parameter, what does it mean when scenecut is reset to -1? Does that mean it will not try to detect scene changes, and just put an I frame every --keyint frames, and when the qpfile tells it to?
kemuri-_9
27th December 2008, 23:37
So if I do not specify a scenecut parameter, what does it mean when scenecut is reset to -1? Does that mean it will not try to detect scene changes, and just put an I frame every --keyint frames, and when the qpfile tells it to?
that is correct.
Kurtnoise
28th December 2008, 14:10
Q: is it safier to use the qpfile or edit the stats file (in a 2-passes scenario) to do this task ?
kemuri-_9
28th December 2008, 16:00
using the qpfile to place frames (granted you know what you're doing here too)
will be safer as you're telling x264 to place frames (IDRs in this case) in a proper way.
editing the .stats can have undesirable side effects...
I may look into scenecut sometime soon and see if can determine what causes it to no longer accepts qpfile frame decisions...
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.