Log in

View Full Version : ffmpeg - Cutting and syncing together two identical videos


Rozzy85
11th April 2019, 01:49
Long story short I have two HDTV recordings (h.264 with AC3 audio) of the same show that I need to splice together (they both contain corrupt frames at different times so I want to repair one with good frames from the other). They are both the exact same codec format from the same TV channel, just recorded at different times. For whatever reason ffmpeg just does not join them together correctly and there is always a noticeable pause in playback where the video was joined. The I-frames occur at the same time in both videos so from what I can see it should work but it doesn't. It's like it's not even snapping to the nearest I-frame which are seconds apart and just cutting exactly at the specified time as minor millisecond adjustments make a difference in where the video cuts.

This is my BAT script:

ffmpeg -ss 00:00:11.800 -i D:\splice\1.ts -t 00:40:32.160 -c copy -map 0:v:0 -map 0:a:0 -map 0:a:1 -y Y:\a.ts
ffmpeg -ss 00:40:49.120 -i D:\splice\2.ts -t 00:00:15.640 -c copy -map 0:v:0 -map 0:a:0 -map 0:a:1 -y Y:\b.ts
ffmpeg -ss 00:40:59.600 -i D:\splice\1.ts -t 00:45:20.920 -c copy -map 0:v:0 -map 0:a:0 -map 0:a:1 -y Y:\c.ts
ffmpeg -i "concat:Y:\a.ts|Y:\b.ts|Y:\c.ts" -c copy -map 0:v:0 -map 0:a:0 -map 0:a:1 -y Y:\spliced.mkv


Joining them in AVISynth works fine (this is where I get the frame timings from to paste into the BAT script) and I would just use it but it but it has a nasty habit of ruining the timestamps which results in a jittery frame rate. I could just re-encode but I've rather not and only do it as a last resort. I've tried commands such as '-avoid_negative_ts make_zero' but nothing makes any difference.

Selur
12th April 2019, 04:26
may be using mkvtoolnix (mkvmerge) instead of ffmpeg helps,...