0

I have a few large video files (in various formats: .avi, .mp4 and .mkv) which only contain a few interesting scenes I want to keep. I'm looking for a way to cut these scenes out of the original video, but without quality loss.

The first attempt I made was with AviDemux where I indicated the start and end position, and performed a copy of both video and audio. Sometimes this works, however, the cuts are not always made exactly where I wanted them to be. As I understand, this has to do with the way video is saved, and had to do with I-frames of keyframes if I'm correct. Cuts have to start from a keyframe in order to be saved lossless, as far as I can tell.

So I made another attempt using ffmpeg with the following command:

ffmpeg -i inputfile -ss 05:05.153 -to 06:06.264 outputfile

This way I end up with a file cut at the exact start and end timestamp I specified, but after reading up on ffmpeg it seems that this way the video isn't saved as a copy, rather as a recompressed (transcoded?) version. In other words, quality is lost.

I've read the following related question How to cut part of MP4 file using FFmpeg without reencoding? and the following website http://loopduplicate.com/content/lossless-video-cut-with-ffmpeg and as far as I can tell I have a choice between lossless (starting from an I-frame) or lossy (starting from an exact timestamp).

So this leaves me with the following questions:

  • is it possible to perform a lossless copy starting from an exact frame, ending with an exact frame?
  • if so, can this be done with ffmpeg? And what is the correct command/syntax?
  • is there an ideal format to do this? Should for example an .avi source be saved as an .avi file or does this not matter? What about mp4/mkv?
  • in case this is not possible: why isn't this possible? I'd assume that (in order to play a video) the original data needs to be decompressed and streamed to the screen, why can this same data not be streamed lossless to a new file on disk?

Please also take into account that, while I am an IT professional, video editing is not my strong point: while I have some basic knowledge, I am far from a knowledgeable user, and certainly no expert. Nevertheless, I'd like to understand what I'm doing and why some things can or cannot be done.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.