[FFmpeg-user] [ffmpeg] An idea to mix re-encoding with copy to get a fast and precise cut

Mohammed Hamdy msvbnet at hotmail.com
Sun Jul 26 01:08:58 EEST 2020


Hi,

I have an idea to make ffmpeg do a fast and precise cut, by re-ncoding just shorts parts around the cut points, and copy the rest of the desired segment  without re-encoding. I wish it can be done. Details:



suppose I want to generate a new video that doesn't contain the chuck starts at t1 to t2. I want ffmpeg to do this to divide the segment (t1, t2) to 3 parts:

  1.  a part (t1-x, t1+y), which is a complete encoded block that should be re-encoded to be able to copy the part (t1, y) precisely.
  2.  a part (t2-z, t3+w), which is a complete encoded block that should be re-encoded to be able to copy the part (z, t2) precisely.
  3.  a middle part (y, z) which contains complete encoded blocks, where it can be copied as is.

Then join the 3 parts resulted from the above steps. Note that the first two parts are expected to be small (and one of them or both can be zero length), so, the re-encoding process will be fast. This will make us able to have exact cuts with slightly slower operation but still super faster than re-encoding the full video. It can be even faster if we can do multiple cuts with one command, so we traverse the frames once.

So, can I do that today with ffmpeg? Or, can ffmpeg support it soon?



More information about the ffmpeg-user mailing list