5

I am using the following filter_complex to put 2 videos of resolution 320 x 240, one right next to the other:

-filter_complex "[v1][v2]hstack=inputs=2[videoout]"

This works great, but now I was wondering how could I do it, so that I could add a small padding between them. Let's say for instance 5 black pixels (even though I would love to be able to customize the color or at least the distance).

How could I do that?

4

First, setup a color filter of the same height, and then add it to the hstack

-filter_complex "color=black:5x240[c];[v1][c][v2]hstack=inputs=3:shortest=1[videoout]"

See the options for the color filter here.


Alternate method is

-filter_complex "[0]pad=iw+5:ih:color=black[0v];[0v][v2]hstack[videoout]"
  • I added this filter, and now my video grows endlessly. Before I had a 20 second video, and now I had to interrupt the process, because it grew without limit... – Enrique Moreno Tent May 14 '16 at 11:44
  • Now I get a "Option 'shortest' not found" – Enrique Moreno Tent May 14 '16 at 11:56
  • shortest=1 works here. Recheck for typos..etc. – Gyan May 14 '16 at 12:03
  • It does not... ffmpeg version? Mine is 2.8.6 – Enrique Moreno Tent May 14 '16 at 12:05
  • You need a build from Dec 2015 or later. Use alt method instead. – Gyan May 14 '16 at 12:07
1

There is a way to achieve this result that may be more relevant to your interests:

Problem: Resize videos centering them in the middle of a pre-determined rectangle, letterboxing if needed.

Answer: https://superuser.com/questions/547296/resizing-videos-with-ffmpeg-avconv-to-fit-into-static-sized-player

The key line from the answer:

ffmpeg -i input -vf "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2" output

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.