I download a lot of FLVs to edit and often the keyframes are 10 to 12 seconds apart, which makes it very difficult to do lossless keyframe editing without losing scenes that I want to keep. Worse, often the keyframes don't change when the scene changes, they just seem to change every 10 to 12 seconds regardless of whether the scene has changed or not.
How can i convert these FLVs to a format where the keyframes are much closer together so that I can edit more precisely? And is there a way to do this losslessly, without degrading the video's quality? Thanks.
+ Reply to Thread
Results 1 to 22 of 22
-
-
-
Actually, it depends on the encoder. For decent modern encoders, keyframes are usually inserted at every scene change
@gumbygum - there is no way to do this losslessly, without degrading the quality - unless you keep it uncompressed or losslessly compressed (huge filesizes) . e.g you could encode to a lossless intermediate like lagarith, ut video codec, and edit that, but the filesizes will be enormous. If you re-encode to a lossy format again after the edits , you will lose quality -
The choice of (placement of) keyframes is integral to how it is encoded. You change that placement, you HAVE to reencode.
Scott -
-
OK, thanks for the replies. Well, can I achieve this if I re-encode? If I just use a converter to convert it to MP4 or AVI or other format, how can I make the keyframes be closer together? Or will the keyframes still be 10-12 seconds apart in the new format?
-
-
When you decode the file , is decoded to uncompressed frames, so it doesn't matter where you cut
You can edit wherever you want and if you re-encode you can put keyframes whereever you want . Just set a max keyframe interval . Or you want even more precision you can even use a list with x264 , a qp file -
Thanks. I want to keep it as simple as possible because a lot of this technical stuff goes over my head. What freeware program would you recommend to re-encode the file and specify a keyframe interval?
A lot of these FLVs are H.264s inside. Does that make a difference? Any way a program like FLV Extract can be useful with this problem? -
I have one question.
Are you, by any chance, confusing keyframes with I-frames ? -
-
-
If you're doing this because of editing, it's still not the optimal way to do it .
You wouldn't re-encode with short keyframe intevals then make cuts.
You would edit it first, then encode it, because your cuts will be frame accurate and there will be no problems joining. If you don't need to edit it again later, there is no reason to place keyframes at a certain interval (longer intervals reduce compression efficiency)
But, basically any GUI for x264 will allow you to place a maximum keyframe interval . e.g. ripbot, megui, xvid4psp, dozens of others... Normally "scenecut" is activated - this it will automatically place an IDR frame during a scenechange, but also abide by that max keyframe interval
e.g. if the fps is 30 and you want 2 sec intervals you would specify 60 as the max keyframe interval
A lot of these FLVs are H.264s inside. Does that make a difference? Any way a program like FLV Extract can be useful with this problem?
It was already discussed that lossless (keyframe only cuts) editing isn't an option for you. You have to re-encode -
Thanks for this advice. What I was thinking of doing was to re-encode it with keyframes at 1 second intervals, and then use a lossless keyframe editor to do the edit, so there would only be 1 generation of quality loss, not two. But your idea is better, because I could cut precisely where I want, not compromise by cutting at 1 second intervals.
But what editor can cut FLV files with single frame precision and then re-encode the edited file as an MP4 or whatever? I am not aware of any freeware editor that can do this. -
-
Should I start randomly downloading YouTube videos to see if there is a keyframe on every scene change or do you have a certain FLV vid on YouTube you can point me to?
Normally you specify a min/max key frame distance and a scenecut-threshold, depending on you scene change it might not even quality as a scene change for the encoder.
Leaving B-Frames and OpenGop out, x264 decides whether to use a P-, I-, IDR- frame this was:
Code:if ((distance from previous keyframe) > keyint) { set IDR-frame } else if ( [1 -(P-frame size)/(I-frame size)]<[(scenecut-threshold/100)*(distance from previous keyframe)/ keyint]) { if ((distance from previous keyframe)>=minkeyint) { set IDR-frame } else { set I-frame } } else { set P-frame #if b-frames exist this is replaced by a P- or B- frame decision } encode frame for real.
Frames that stand alone and don't need to refer to another frame.
Key-Frame = I-Frame + is the start of a GOP (group of pictures = number of frames that can be decoded without referring to frames outside of the GOP; That's why cutting on Key-Frames is simple.)
Before H.264, Key- and I-Frames were the same. In H.264 we differentiate between IDR-Frames and I-Frames. -> there can be references to frame before an I-Frame, but there can't be references before an IDR-Frame.Last edited by Selur; 15th Jul 2013 at 07:39.
-
The way I would do it is with avisynth + some encoder or some GUI like ripbot, megui etc....
The cuts are made in avisynth. You can use avspmod or vdub to "see" the cuts
The problem is there is a bit of a learning curve
Alternatively, you could encode them to I-frame lossless intermediates, then edit those, then encode those. The avisynth method will be faster (fewer encoding steps), and a lot less temporary HDD space required
It might be possible with vdub directly (without avisynth) , using the vdub ffinputdriver or directshow input driver, to load the FLV, and using the external encoder feature on experimental builds to access other compressors and containers (normally you can't export in containers other than AVI in vdub). x264vfw can also export mp4 if you use the command line option -
BTW, YT doesn't use open GOP (at least it didn't when I tested it a while back ), so all "I" frames are in fact IDR frames .
(Unless something has changed recently)
Very old youtube FLV videos didn't use h.264/AVC. They used h.263 or sorensen spark . Those are the ones that had big problems with keyframes -
I use a couple of different keyframe editors like Free Video Dub. No point uploading a FLV because this is a problem I have with lots of different FLVs that have widely-spaced I-frames.
-
Well i'd like to avoid a learning curve if possible. Actually after I posted I downloaded the latest Avidemux and was surprised to find that I could edit the FLV precisely and re-encode it with this. Surprised because in the past I've had very little success editing FLVs with Avidemux. I think the result had a few audio glitches, but not the terrible audio sync problems that I almost always had in the past. Thanks much for your advice.
-
The whole point of using your software (which does not appear to be very clever) and an actual video was to replicate your problems.
I do not think you have really solved the issue since if you cut on a non i-frame you will have issues. The software used, Free Video Dub that is, encourages or maybe insists on cutting on an i-frame so can then create the edited video without re-encoding. But to call it lossless is a mis-nomer in the extreme.
Similar Threads
-
Question about how to modify exe file
By jimdagys in forum ComputerReplies: 9Last Post: 29th Oct 2011, 17:59 -
Compress large FLV file to a smaller size FLV file
By RustyBob in forum Video ConversionReplies: 1Last Post: 26th Oct 2011, 17:21 -
Modify playback speed of .mp4 video and or .flv and save.
By jsvez2010 in forum Newbie / General discussionsReplies: 0Last Post: 16th Sep 2011, 18:18 -
Trying to modify .VOB file - why didn't this work?
By brassplyer in forum Authoring (DVD)Replies: 8Last Post: 7th Feb 2011, 22:03 -
FFMPEG Flags for FLV keyframes
By infinull in forum Video ConversionReplies: 0Last Post: 13th Apr 2010, 22:36