I can never get ptQa's solution to work, mostly because I can never figure out what the errors from the filters mean or how to fix them. My solution seems a little clunkier because it can leave behind a mess, but if you're throwing it into a script, the clean up can be automated. I also like this approach because if something goes wrong on step 4, you end up with completed steps 1-3 so recovering from errors is a little more efficient.
The basic strategy is using
-ss to get videos of each segment you want, then join together all the parts for your final version.
Say you have 6 segments ABCDEF each 5 seconds long and you want A (0-5 seconds), C (10-15 seconds) and E (20-25 seconds) you'd do this:
ffmpeg -i abcdef.tvshow -t 5 a.tvshow -ss 10 -t 5 c.tvshow -ss 20 -t 5 e.tvshow
ffmpeg -i abcdef.tvshow -t 0:00:05 a.tvshow -ss 0:00:10 -t 0:00:05 c.tvshow -ss 0:00:20 -t 0:00:05 e.tvshow
That will make files a.tvshow, c.tvshow and e.tvshow. The
-t says how long each clip is, so if c is 30 seconds long you could pass in 30 or 0:00:30. The
-ss option says how far to skip into the source video, so it's always relative to the start of the file.
Then once you have a bunch of video files I make a file
ace-files.txt like this:
Note the "file" at the beginning and the escaped file name after that.
Then the command:
ffmpeg -f concat -i ace-files.txt -c copy ace.tvshow
That concats all the files in
abe-files.txt together, copying their audio and video codecs and makes a file
ace.tvshow which should just be sections a, c and e. Then just remember to delete
Disclaimer: I have no idea how (in)efficient this is compared to the other approaches in terms of
ffmpeg but for my purposes it works better. Hope it helps someone.