I am trying to use ffmpeg (running on Ubuntu 18.04LTS) to clip a video. The general command I am using is:
The current clip was itself clipped from a much larger video file (graduation ceremony), and ffmpeg reports the total clip length to be 10.64 seconds. If it matters, ffmpeg also reports a 'start' of minus 0.007 seconds:Code:ffmpeg -i Input.mkv -ss 00:00:00 -to 00:00:09.500 -vcodec copy -acodec copy -scodec copy Output.mkv
If I run ffprobe on the clip it reports that there are only five keyframes (every two or three seconds or so):Code:Duration: 00:00:10.64, start: -0.007000
If possible, I would like to snip the end off (I am guessing at about 9.5 seconds, but I would likely try a few different times around that), but (if I understand correctly) I need to do that at a keyframe. If I could increase the number of keyframes from five to, say, twenty, then I would be able to be more precise about the start and end of the clip (I think).Code:[FRAME] pkt_pts_time=0.473000 pict_type=I [/FRAME] [FRAME] pkt_pts_time=2.606000 pict_type=I [/FRAME] [FRAME] pkt_pts_time=5.473000 pict_type=I [/FRAME] [FRAME] pkt_pts_time=7.873000 pict_type=I [/FRAME] [FRAME] pkt_pts_time=10.473000 pict_type=I [/FRAME]
Q1) Is that correct about keyframes or have I misunderstood?
Q2) If I do need to start and stop at a keyframe, how can I increase the number of them 'in' the file so that I can cut more precisely?
I am pretty much a newb at this stuff, so apologies if I have not given some info that is important - just let me know what is required and how to find it, and I will post more details.
+ Reply to Thread
Results 1 to 2 of 2
The only way to create more keyframes is to reencode the video. If you're going to reencode the video you might as well just reencode the part you want (0 to 9.5 seconds). There are "smart encoders" that only reencode cut GOPs -- like VideoRedo. Or you could do a smart reencode your self by saving the first part, 0 to 7.873 seconds, with "-vcodec copy", reencoding from 7.873 seconds to 9.5 seconds, then appending the two.
If you only need to cut a bit off the end of the file, AviDemux will allow you to mark out on a P frame. That might be close enough for you.
Last edited by jagabo; 3rd Jun 2021 at 08:44.