View Full Version : "forcing" keyframes
librex
12th March 2002, 11:33
it's something related to another thread in the Divx5 encoding forum but as nobody reads long threads anyway, here it is (sorry for cross-posting if it annoys you!) :
As splitting a movie with Virtualdub and/or Nandub is not really easy with DivX5 (keyframes are all out of sequences, follow this link for details : http://forum.doom9.org/showthread.php?s=&threadid=19912), I was wondering if there was a way to "force" a specific frame into becoming a keyframe.
Suppose I want to cut a movie EXACTLY on a frame but it isnt a keyframe. One nice thing would be to transform this frame into a keyframe by getting all the necessary infos from the previous frames (dont think bi-directionnal yet!) and to re-encode the subsequent frames relative to this new keyframe (up until the next key, of course). This woulndt change the number of frames nor the order they are in, it would only increase the avi size.
Is this dreaming or can it be done?
thanks for your answer,
-librex-
Ecuador
12th March 2002, 13:02
One obvious (though not really quick solution) is this:
For example you want frame 100 to be a keyframe, while the closest keyframes are 50 and 120. Just re-encode frames 50-99 and 100-119 separatelly. At least that is what I do to cut out some unwanted frames (commercials) from downloaded programs...
If anyone has an even easier solution, let us know.
librex
12th March 2002, 22:56
I'm not following..
how can you recompress a part of an avi w/o cutting it into smaller files? in your example, you would could not "extract" the 50-99 segment easily as this would imply having the frame #100 as your cutting point (which must be a valid keyframe).
could you explain me how you manage to recompress arbitrary chunks of an avi file? I,m still quite a newbie at this so excuse my limited virtuadubbing knowledges..
thanks!
Ecuador
12th March 2002, 23:42
When you cut an avi file you have to worry about keframes. When you re-compress an avi, you can start at any frame.
In my example, you have to start at frame 50 because you will not re-compress the part 1-49, and you stop at frame 119 because you want to leave the segment 120-end as it is.
librex
13th March 2002, 11:32
I know i'm thickskulled but somehow, I fail to see how to recompress a segment without having to cut and append said segments.
could you give me a step by step procedure for doing this with vdub?
Thanks for your help!
Ecuador
13th March 2002, 12:48
Direct Stream copy frames 1-49 (Segment 1)
Recompress frames 50-99 (Seg 2)
Recompress frames 100-119 (Seg 3)
Direct Stream copy frames 120-end (Segment 4)
Open the first segment and append the other three. All this to force a keyframe at frame 100... I use such a procedure if I want to remove for example frames 90-110 (seg 2 becomes 50-89 and seg 3 becomes 111-119).
You don't need to re-encode Segment 2 (50 - 99), you can also direct stream copy it. This is true if you don't use B-frames.
Otherwise it depends where your B-frames are. You might need to re-encode Segment 2.
bb
madoka
14th March 2002, 01:25
Perhaps I missing something, but if you have the original source material, why not just split it into two segments and encode them in separate jobs? The first frame is always a key frame, am I mistaken?
Well, you wouldn't want to re-encode if you had the original source, because it degrades quality. But if you have nothing but the DivX file - e.g. if it was a direct DivX capture - then you need to create a keyframe at the split position.
bb
librex
14th March 2002, 17:30
It is easier to cut a movie when it has been encoded!
I always try to cut an AVI where it makes sense. If I have to swap the CDs, I just dont want the screen to freeze right in the middle of an action scene.. With that in mind, the filesizes must also be within the limits (normally the 1st part is a bit smaller as I put other stuff with the movie like synopsis etc. etc.)
So that's why I was asking the question in the first place. With DivX5, I find it more difficult to get a "right" keyframe as there's a strange probleme of frames ordering. You dont get the same frame in Vdub when you move forward that if you move backward.
What I wanted to do is to force a specific frame into keyframe. I'll try Ecuador's solution later this week to see if it helps.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.