ffmpeg - merge images with video

0

I have a video with audio that I am trying to merge with 2 images - one image before the video starts and one image after the video ends - but right now I am getting this error -

Stream specifier ':a' in filtergraph description [0:v] [0:a] [1:v] [2:a] concat=n=3:v=1:a=1 [v] [a] matches no streams.

This is the code I am using -

 ffmpeg \
    -loop 1 -framerate 24 -t 10 -i default_start.png \
    -i output-first.mp4 \
    -loop 1 -framerate 24 -t 10 -i default_end.png \
    -f lavfi -t 3 -i anullsrc \
    -filter_complex "[0:v] [0:a] [1:v] [2:a] concat=n=3:v=1:a=1 [v] [a]" \
    -c:v libx264 -c:a aac -map "[v]" -map "[a]" -y output-second.mp4 2>&1

EDIT

I am also trying to use 2 different commands, each using 1 image file instead of two --

// Image at start only
    ffmpeg -y \
        -loop 1 -framerate 24 -t 10 -i default_start.png \
        -i output-first.mp4 \
        -f lavfi -t 3 -i anullsrc \
        -filter_complex "[0:v] [2:a] [1:v] [1:a] [2:v] [3:a] concat=n=2:v=1:a=1 [v] [a]" \
        -c:v libx264 -c:a aac -map "[v]" -map "[a]" output-second.mp4 2>&1


// Image at end only
    ffmpeg -y \
        -i output-first.mp4 \
        -loop 1 -framerate 24 -t 10 -i default_end.png \
        -f lavfi -t 3 -i anullsrc \
        -filter_complex "[0:v] [3:a] [1:v] [1:a] [2:v] [3:a] concat=n=3:v=1:a=1 [v] [a]" \
        -c:v libx264 -c:a aac -map "[v]" -map "[a]" output-second.mp4 2>&1

Rich

Posted 2018-08-09T21:28:02.903

Reputation: 119

Answers

3

You need to map the concat inputs with the corresponding file inputs:

ffmpeg -y \
    -loop 1 -framerate 24 -t 10 -i default_start.png \
    -i output-first.mp4 \
    -loop 1 -framerate 24 -t 10 -i default_end.png \
    -f lavfi -t 3 -i anullsrc \
    -filter_complex "[0:v] [3:a] [1:v] [1:a] [2:v] [3:a] concat=n=3:v=1:a=1 [v] [a]" \
    -c:v libx264 -c:a aac -map "[v]" -map "[a]" output-second.mp4

llogan

Posted 2018-08-09T21:28:02.903

Reputation: 31 929

Im getting this error -- [Parsed_concat_0 @ 0x24bbc80] Input link in1:v0 parameters (size 1280x720, SAR 0:1) do not match the corresponding output link in0:v0 parameters (1920x1080, SAR 0:1) [Parsed_concat_0 @ 0x24bbc80] 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 #2:0 Conversion failed! – Rich – 2018-08-10T05:04:56.030

For concat, all videos must have the same resolution and sample aspect ratio. This should be checked and conformed prior to concat. However, you can tell the filter to ignore such errors using unsafe=1 (add it after a=1 with a colon). – Gyan – 2018-08-10T05:25:20.970

is there a way to resize the image file to fit? – Rich – 2018-08-10T06:01:10.720

@Rich See https://superuser.com/a/1052349/48078

– slhck – 2018-08-10T06:25:37.693

ok thanks, i've accepted your answer. I've also added a edit to my question that i need help with, if thats possible. – Rich – 2018-08-10T15:42:21.997

@Rich For example #2: "[0:v] [2:a] [1:v] [1:a] concat=n=2:v=1:a=1 [v] [a]". For example #3: "[0:v] [0:a] [1:v] [2:a] concat=n=2:v=1:a=1 [v] [a]". As for the error in the first comment: this is why you should always include the complete console output from your commands in your question so we can anticipate potential issues and provide more suitable, less generic answers for your specific case. – llogan – 2018-08-10T22:02:38.597