1

I want to cut lengthy segments of a video file and then join them. But without re encoding precise cutting isn't possible as ffmpeg seeks to the key frame before my listed time stamp and cuts from that key frame or in some cases cuts from that key frame and use some kind of table to play video as intended. When I join such cut segments the joined file shows those unwanted sections due to some inability of concat fun i guess. this is how I am trying to concat those segments:

ffmpeg -f concat -i Cam01.txt -c copy Cam01.mp4

To solve this problem with lesser re encoding I thought to cut the video in two parts; first cut without re encoding from start to just before that key frame which will be faster and then in the second part cut with re encoding from that key frame to my desired frame, which will be few seconds and then join those two parts to have my segment.

Now I have two questions:

1: how can I get time stamp of a key frame before any time stamp?

2: Is there any problem in how i am joining segments so that in some cases it shows those unwanted parts in my joined file?

Or some way I could get time stamps of key frames in an entered range of time if getting to a key frame before any time stamp wont be possible.

Saif
  • 121

1 Answers1

1

for 1. you can use

 ffprobe -select_streams v -show_frames youfile.mp4

to get a list of frames, key frames will be marked with 'key_frame=1' and their time stamp so you could parse that to find your nearest key frame.

for 2. you are joining them just fine, i've had similar issues with fast seeking (-ss before -i) into streams produced using the concat muxer in the end I just calculated which segments to use outside of ffmpeg and then putting up with the slow seek (-ss after -i)