Alex
Alex

Reputation: 583

FFmpeg filter_complex concat gives only first input on crop

I've encoutered problem when using concat and crop with multiple inputs and multiple outputs. Here's

ffmpeg -y \
-i input_1.mp4 \
-i input_2.mp4 \
-i input_3.mp4 \
-i input_4.mp4 \
-filter_complex "[0:v][1:v][2:v][3:v]concat=n=4:v=1:a=0[v];\
[v]crop=3840:1080:960:0[center];\
[v]crop=960:1080:0:0[left];\
[v]crop=960:1080:4800:0[right]" \
-map "[center]" -c:v libx264 -preset faster -b:v 20000k -an -pix_fmt yuv420p -tune zerolatency -tune fastdecode "Output_Center.mp4" \
-map "[left]" -c:v libx264 -preset faster -b:v 20000k -an -pix_fmt yuv420p -tune zerolatency -tune fastdecode "Output_Left.mp4" \
-map "[right]" -c:v libx264 -preset faster -b:v 20000k -an -pix_fmt yuv420p -tune zerolatency -tune fastdecode "Output_Right.mp4"

So there I concatenate 4 inputs into 1 stream [v], then I crop certain parts to [center], [left] and [right]

For first output (center) it works as expected, output video duration is right (1 + 2 + 3 + 4 input durations), but for left and right outputs duration completely match duration of the first input.

I've also tried use [v1] as output of concat, that didn't help

Upvotes: 1

Views: 1515

Answers (1)

Gyan
Gyan

Reputation: 92928

Intermediate filter pad outputs can't be reused. For multiple use, add split with different labels for the outputs i.e.

-filter_complex "[0:v][1:v][2:v][3:v]concat=n=4:v=1:a=0,split=3[v1][v2][v3];\
[v1]crop=3840:1080:960:0[center];\
[v2]crop=960:1080:0:0[left];\
[v3]crop=960:1080:4800:0[right]" \

Upvotes: 3

Related Questions