0

I was able to find this thread on cutting a specific portion out of a file. It's not very useful since I'm looking to do the exact opposite which is to remove the selected portion of the video.

This user's solution for extracting a part without re-encoding works pretty well. Can I do something similar to remove a selection portion instead?

I prefer not having to re-encode, but I'm fine either way so any solution would do.

Aulis Ronkainen
  • 2,612
  • 42
  • 29
  • 27
Yimiko
  • 1
  • 1
    Potential solution: https://superuser.com/questions/1385882/how-to-discard-a-part-of-a-mp4-with-ffmpeg – Mokubai Feb 20 '22 at 13:19
  • You may use `concat` demuxer with `inpoint` and `outpoint` as described in the [following post](https://stackoverflow.com/a/42750147/4926757). It is done without re-encoding. Without re-encoding has some limitations (it cuts only in key frames, and it's not always working). – Rotem Feb 20 '22 at 17:09

1 Answers1

0

Extract the parts you want by using the as codec the "Copy" option -c:v copy -c:a copy

Let's say you have a 6 minutes video and you don't want the parts from 2-3 min and from 4-5 min:

ffmpeg -ss 00:00:00 -to 00:02:00 -i input.mp4 -c:v copy -c:a copy input_part1.mp4
ffmpeg -ss 00:03:00 -to 00:04:00 -i input.mp4 -c:v copy -c:a copy input_part2.mp4
ffmpeg -ss 00:05:00 -to 00:06:00 -i input.mp4 -c:v copy -c:a copy input_part3.mp4

Create a text file for the files you extracted (filelist.txt)

file 'input_part1.mp4'
file 'input_part2.mp4'
file 'input_part3.mp4'

Then join them together with something like this

ffmpeg -safe 0 -f concat -i filelist.txt -c copy output.mp4

output.mp4 should not have the parts you don't want.

Ricardo Bohner
  • 3,903
  • 2
  • 18
  • 12