Thursday 7 December 2017

How can I remove multiple segments from a video using FFmpeg?


I am trying to delete a few sections of a video using FFmpeg.


For example, imagine if you recorded a show on television and wanted to cut out the commercials. This is simple with a GUI video-editor; you just mark the beginning and ending of each clip to be removed, and select delete. I am trying to do the same thing from the command-line with FFmpeg.


I know how to cut a single segment to a new video like so:


ffmpeg -i input.avi -ss 00:00:20 -t 00:00:05 -map 0 -codec copy output.avi

This cuts a five-second clip and saves it as a new video file, but how can I do the opposite and save the whole video without the specified clip, and how I can I specify multiple clips to be removed?


For example, if my video could be represented by ABCDEFG, I would like to create a new one that would consist of ACDFG.



Answer



Although the answer provided by ptQa seems to work, I have developed an other solution which has prooved to work fine.


Essentially, what I do is to cut one video for each part of the original video that I want to include on my result. Later, I concatenate them with the Concat Demuxer explained here.


The solution is the same that waht I have tried first and presented sync problems. What I have added is the command -avoid_negative_ts 1 when generating the different videos. With this solution, the sync problems dissapear.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...