[FFmpeg-user] Multiple parts of a video

Bo Berglund bo.berglund at gmail.com
Tue May 31 19:15:17 EEST 2022

On Tue, 31 May 2022 13:15:02 +0200, Michael Koch <astroelectronic at t-online.de>

>Am 31.05.2022 um 11:17 schrieb Bo Berglund:
>> On Sun, 29 May 2022 13:17:55 +0200, Michael Koch <astroelectronic at t-online.de>
>> wrote:
>>>>> Using concat filter.
>>>> That is exactly what I already know: cutting the different parts.
>>>> Probably one command for each part and then concatenate them.
>>>> So n + 1 commands.
>>>> My question was: can it be done with one command?
>>> Please have a look at
>>> https://trac.ffmpeg.org/wiki/Concatenate
>>> "Concat demuxer", "Concat protocol" and "Concat filter" are three
>>> different things.
>>> You did use the concat demuxer. Now if you want to do all in one line,
>>> you must use the concat filter.
>>> Michael
>> Stepping in here due to the interesting topic:
>> I am daily using a tool I created myself to use ffmpeg to remove ads from
>> recorded mp4 TV news videos.
>> What I do is the following:
>> - I manually scan the video to find the start/end times of the ads (seconds)
>> - From this list the tool creates the ffmpeg commands to extract the parts
>> *between* the ads as separate numbered mp4 files
>> - Then a list of these small files is written to a file $JOINFILE
>> - This is then used in an ffmpeg call like this:
>>    ffmpeg -f concat -safe 0 -i $JOINFILE -c copy $TARGETFILE
>> - When this is done the small files and $JOINFILE are deleted
>> So reading this thread I get the feeling that there is a way to use the list of
>> cut times in a *single ffmpeg command* to create the output mp4 file *without*
>> creating the list file and essentially doing everything in this single ffmpeg
>> command.
>I have a short example in chapter 2.57 of my book:

Michael, thanks a lot for your input!

When using your book link I landed in a directory where I already had the April
25, 2021 version! Downloaded 13 months ago...

This new version from May 28, 2022 is greatly expanded going from 553 to 821
Great work, thank you!

So when I read the ch 2.57 I see that the sources of the concatenation operation
are actual multiple video files.

This is what I am already doing but it is a multiple-step process where there is
one step where the short video files are created by cutting out of the main
input video files based on start time and length for each cut. (Resolution:

Then these are pasted together using the concat with copy since they are cutouts
from the same single input video and thus share the format.

What has been asked in this thread is if there is a way to *combine* these
operations such that there is no need for intermediate files...

I.e. can ffmpeg be commanded to extract the sections to concatenate and feed
them one after another into the concat operation without landing in a temp file

Further notes about your book example 2.57:

The first line states:
"In this example the concat filter is used for input videos of the same size and
no audio."

No audio is a non-starter for me.

I need the audio to also be present in the output with preserved audio/video

It also says:
"This filter does re-encode the videos, ..."

Also something I want to avoid since it takes a long time to do and seems
un-necessary since all of the parts being concatenated come from one and the
same source video where parts are being edited out. Thus they share the same

Basically when editing a single source video (with audio) the re-encoding should
not be needed, right?
Or am I missing something due to the use of compression?

Bo Berglund
Developer in Sweden

More information about the ffmpeg-user mailing list