Thursday, September 21, 2023
 Popular · Latest · Hot · Upcoming
rated 0 times [  43] [ 0]  / answers: 1 / hits: 21840  / 11 Months ago, sat, november 26, 2022, 1:04:56

I am looking for an app to help me chop bits off start and end of an mp4 file efficiently and losslessly.

e.g. is there something that lets me find a keyframe and copy the lot between that and another keyframe, without needing to re-encode the lot (slow and lossy), and without losing AV sync?

By mp4, I mean H264 video + AAC audio in an MP4 container

Pre h264 days Avidemux was an excellent tool for this as you can reuse the original encoded streams meaning no loss and take just a few seconds to create the trimmed version, but it is hopeless with h264 - opening one gives you two options: use safe mode (which loses AV sync massively) or use the dangerous mode which immediately crashes it.

AFAIK, Openshot, Kdenlive, Pitivi etc. will all do this by decoding and recoding (slow and lossy).

Seems a simple thing (probably showing my lack of knowledge here!), so was wondering if I'm missing something.

More From » 12.04



ffmpeg -i source.mp4 -ss 00:00:00 -t 00:00:00 -vcodec copy -acodec copy splice.mp4

This will take source.mp4 and, using the same audio and video codecs and not degrading quality, take -t time after -ss start time video and output your splice.mp4

Please note that the timing is very sensitive to formatting (above is one example formatting). Also, in some distributions, ffmpeg has been replaced with avconv. Simply run the above command and replace the word ffmpeg with avconv to solve this.

Another excellent source of information on this topic. (Thanks @pbhj)

[#27721] Sunday, November 27, 2022, 11 Months  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 485
Total Questions: 88
Total Answers: 106

Location: Central African Republic
Member since Mon, Aug 10, 2020
3 Years ago