Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FFmpeg doesn't recognize correct input height in hstack command

Having an issue with an hstack FFmpeg command that has stumped me.

input1 and input2 are both vertical 360x640 videos. I am cropping input1 to a square, merging it vertically with input2, then cropping a vertical strip off each side of the resulting video and horizontally merging these three videos (left strip, middle vertically-stacked video, right strip).

ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex [0:v]crop=360:360:0:140,fps=30[v0],[1:v]fps=30[v1],[v0][v1]vstack=inputs=2[m],[m]crop=101:ih:0:0[l],[m]crop=101:ih:259:0[r],[l][m][r]hstack=inputs=3[v];[0:a][1:a]amix[a] -map [v] -map [a] -preset ultrafast ./stackedOutput.mp4

When I run this, I get an error:

[Parsed_hstack_6 @ 0x7ff5394482c0] Input 1 height 640 does not match input 0 height 1000. [Parsed_hstack_6 @ 0x7ff5394482c0] Failed to configure output pad on Parsed_hstack_6

(Full FFmpeg output here.)

But the height of [m] (Input 1 in hstack) is not 640, it's 1000. I have verified this when the commands are run independently.

Why is FFmpeg not recognizing the correct height of [m]? Any help or pointers greatly appreciated! Thanks in advance!

like image 987
lach_codes Avatar asked Dec 17 '25 21:12

lach_codes


1 Answers

Use:

ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "[0:v]crop=360:360:0:140,fps=30[v0];[1:v]fps=30[v1];[v0][v1]vstack=inputs=2,split=3[lc][m][rc];[lc]crop=101:ih:0:0[l];[rc]crop=101:ih:259:0[r];[l][m][r]hstack=inputs=3[v];[0:a][1:a]amix[a]" -map "[v]" -map "[a]" -preset ultrafast ./stackedOutput.mp4

Two problems:

  1. Your syntax is incorrect. Filters in the same linear chain are separated by commas, and distinct linear chains of filters are separated by semicolons. See filtering introduction.

  2. You can't re-use the output from a filter multiple times. In your command [m] was already consumed by the first crop, so it is no longer available for the following crop and hstack. The split filter can be used to make multiple copies of a filter output.

like image 57
llogan Avatar answered Dec 21 '25 05:12

llogan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!