How to cut on real keyframes in copy mode using ffmpeg commands? #2235
Unanswered
Dean-Corso
asked this question in
Q&A
Replies: 1 comment
-
Hi. I believe this is related to #1216 - I don't have any definite answer to that unfortunately. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi guys,
just would like to ask an old question I still found no solution for it. Normally I'm using video editing tools to see the keyframe locations in the video stream and to jump on them and doing some stream copy cuts. Tools like VD1 / AviDemux etc do support that. Good so far. Now I was trying to do some simple keyframe cuts using just ffmpeg CLI like lossless also does to do some ROUND ABOUT cuts near at the next or previous keyframe but somehow I never get this working same good as when using AviDemux and select any part right at the keyframe and output that part in copy mode.
Example: I have a video with a length of 50 seconds and very 10 seconds is a keyframe (5). But now lets imagine I don't know the exact keyframe time stamps (also don't wanna use exact time stamps) and I just want to create some ROUND ABOUT ~ Keyframe cut telling ffmpeg to cut NEAR at the time I want to make the cut (just one single selection) you know. So in this case I do expect that ffmpeg does find & seek by itself the nearest next / pre / close keyframe position of my entire selection and it should correct it and using the nearest keyframe times, right.
As I said, my video is 50 seconds long and has every 10 seconds 1 keyframe. My custom time selection is this...
...and a simple ffmpeg command would look like this...
ffmpeg -ss 5.00000 -i "Video.mp4" -t 20.00000 -c copy "VideoOut.mp4"
...so I did select start and end time of selection exact on NOT keyframe location in the middle. Normally ffmpeg should now correct my selection of -ss 5 seconds start to next keyframe at -ss 10 or -ss 00 and the end time it should set to -t 25 or -t 15 what would hit the keyframes. But somehow ffmpeg / lossless don't do it and shifting the video around using -avoid_negative_ts X but also with this command the keyframe cut is never done at the keyframes of the original video what was my goal. So why does it not work? The final results in ANY case is always messed up. So is the reason that ffmpeg really CAN'T find & seek the nearest keyframe positions + using them or what is it?
Sometimes I don't wanna edit some footage in a video editor to make some accurate keyframe selection/s and or cut and export it via stream copy. Sometimes I just wanna do a simple round about single selection and copy that part into new output file as stream copy. Lets say I have a 60 minutes YT video and just want to stream copy few minutes inside of it like from minute 20 - 30. So its not important when the selections gets corrected by ffmpeg to set accurate cut points ON the real keyframes to make the video selection more or less you know. But it is important that ffmpeg DOES set & use the real keyframe position to make a 100% accurate stream copy cut without any issues / video shifting etc whatever what. So my question is whether it is possible to tell ffmpeg that or not. Maybe you are experienced in dealing with ffmpeg and could tell me whether its possible and if yes how to do it by using some specific ffmpeg commands. Thank you.
Beta Was this translation helpful? Give feedback.
All reactions