[FFmpeg-user] How to properly pasting same-size video parts together into one output?

Nikita Zlobin nick87720z at gmail.com
Tue Jan 25 12:11:41 EET 2022

I would try separate separate concats for audio and video,
as they are demuxed anyway before filtergraph.

In Tue, 25 Jan 2022 09:35:59 +0100
Bo Berglund <bo.berglund at gmail.com> wrote:

> This is about ffmpeg usage on Linux...
> I am nightly downloading news shows from several sources and
> sometimes a show from one might be bad at the end and another at the
> beginning. So I use ffmpeg to cut out the good parts from both and
> then paste them together using this method in a "paste" script:
> 1) create a joinfile listing all of the parts to paste
> 2) create the output video using this:
>    ffmpeg -f concat -safe 0 -i $JOINFILE -c copy $TARGETFILE
> This always works for parts extracted from the same video (commercial
> removal) and often also from parts coming from different download
> sources. The download script always converts the videos on the fly to
> the same 852x480 pixel format.
> But sometimes the video parts seems to paste OK but the audio is
> either missing in later parts or severely shifted (by many seconds it
> seems like).
> Each small part when played by itself is perfectly OK.
> How would the command look like in order to combine the video parts
> such that audio and video are not shifted?
> I have tried this but it failed:
> ffmpeg -hide_banner -i input.1.mp4 -i input.2.mp4 -filter_complex
> "[0:v] [0:a] [1:v] [1:a] concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map
> "[a]" output.mp4
> Output (after the normal ffmpeg stuff):
> [Parsed_concat_0 @ 0x55c0837c7400] Input link in0:v0 parameters (size
> 852x480, SAR 0:1) do not match the corresponding output link in0:v0
> parameters (852x480, SAR 640:639)
> [Parsed_concat_0 @ 0x55c0837c7400] Failed to configure output pad on
> Parsed_concat_0
> Error reinitializing filters!
> Failed to inject frame into filter network: Invalid argument
> Error while processing the decoded data for stream #1:0
> Conversion failed!
> I don't know what the (852x480,SAR 640:639) part of the output means,
> so I am clueless here.
> I would like to create a paste script that can handle these
> situations when the existing script using the command on top does not
> work. The existing paste script is very fast but it does not
> re-encode anything, I believe.
> Any suggestions welcome.

More information about the ffmpeg-user mailing list