0

Say I want to remove the part between second 60 and the second 200:

file video
outpoint 60
file video
inpoint 200

then running the ffmpeg concat command:

ffmpeg -f concat -i input.txt -c copy output.mp4

while this works, but on second 60 where the cut happened there will be a subtle jitter and lag then the video plays ok after that... how can I fix this because this is driving me nuts!! Keep in mind I don't want ffmpeg to re-encode the video.

3
  • 1
    There is probably no key frame at exactly 60 seconds thus the "jitter". You would have to rerender to fix this, that would put a key frame at the beginning of the video (60 seconds). Commented Jun 19 at 4:30
  • @RicardoBohner, so basically, the only way to fix this is to re-encode? Commented Jun 19 at 11:32
  • 1
    I'm not a ffmpeg expert but I belive yes. Commented Jun 19 at 12:46

2 Answers 2

0

You need to cut each part out:

ffmpeg -hide_banner -i input.mp4 -c copy -to 00:01:00 -avoid_negative_ts auto output1.mkv

ffmpeg -hide_banner -i input.mp4 -c copy -ss 00:03:20 -avoid_negative_ts auto output2.mkv

Then -concat those two files:

list.txt:

file '/path/to/output1.mkv'
file '/path/to/output2.mkv'
ffmpeg -hide_banner -f concat -safe 0 -i list.txt -c copy -avoid_negative_ts make_zero final_output.mkv

Using -c copy will cut at the closest keyframe. If you need exact cuts at the timestamps, re-encoding is unavoidable.

0

You can fix the stutter by demuxing and remuxing the streams. Below can be run from a single script.

ffmpeg -i output.mp4 -c:v copy stream1.h264 -c:a copy stream2.aac

ffmpeg -i stream1.h264 -i stream2.aac -c copy output2.mp4

del stream1.h264,stream2.aac

There will still be issues with Non-monotonic DTS and Timestamps. If this is a problem, you can open in Avidemux and it should allow you to fix on load before outputting in copy mode. Although if you implement Avidemux, there's an argument to do everything with the one app.

Latest Avidemux can be found at: https://www.avidemux.org/nightly/win64/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .