[FFmpeg-user] help needed, combine three simple calls into one?

Carl Zwanzig cpz at tuunq.com
Fri Nov 27 20:34:58 EET 2020


On 11/26/2020 5:52 AM, Ram Shaffir wrote:
>> From: ffmpeg-user <ffmpeg-user-bounces at ffmpeg.org> On Behalf Of Ram
>> Shaffir
>> Sent: Thursday, November 26, 2020 2:53 PM
>>  Is it possible to combine the following three calls into one call instead?

> ffmpeg -y -f concat -safe 0 -copyts -i videoList.txt -muxpreload 0 -muxdelay 0 -c copy -b:a 128K -cpu-used 0 -preset slow -movflags +faststart -f mp4 concat.mp4
Make one file out of ??? files. Does this also re-encode anything? (What are 
the input formats? see below)

> ffmpeg -y -i concat.mp4 -itsoffset 1.9 -i concat.mp4 -c:a aac -c:v copy -map 0:v:0 -map 1:a:0 -f mp4 audioFixed.mp4
Shift the audio a bit and re-mux.

> ffmpeg -y -i audioFixed.mp4 -ss 2 -to 17 -c:v copy -c:a aac -f mp4 final.mp4
Select part of the now-shifted file.


Sometimes, there is no gain to creating more complex directives. In this 
case, it might reduce the amount of de/remux work, but the time-shift 
suggests pretty much means you're stuck with intermediate file(s). Might 
combine the 2nd and 3rd commands.

Since you only select 17 seconds from the output, you could add a 20 second 
limit to the first step, which would potentially make the intermediate files 
smaller. (Another thing we don't know.)

Consider using another _container_ type for the intermediate file(s) (e.g. 
nut, avi, or mkv, which can hold the mp4 data).

You could also, in the first pass, write to separate files for audio and 
video, which might simplify the shift/remux process and then apply the 
time-based selection to that (see 
https://trac.ffmpeg.org/wiki/Creating%20multiple%20outputs).

Move the "faststart" to the last step since that's where it would matter (it 
gets in the way of piping, if used, and it adds a second file write pass).

I haven't yet tried any of this, and there's probably an error somewhere in 
there.

As usual, it really helps to see the command output so we know the file 
formats/etc.

z!


More information about the ffmpeg-user mailing list