0

I have two videos the same size and pixel format (about 240x360) left and right that I want to stitch together.

I'm using:

ffmpeg -i left.mp4 -i right.mp4  -filter_complex "[0:v][1:v]hstack=inputs=2:shortest=1[v]; [0:a][1:a]amerge[a]" -map "[v]" -map "[a]" -ac 2 -shortest -y output.mp4

which takes about 15 seconds on a 3 core machine. I see x1.25 on the conversion line.

I know this isnt too bad, but any speed up I can make is going to help a lot as its in heavy use.

Any ideas how I can improve this?

llogan
  • 121,796
  • 28
  • 232
  • 243
ianf
  • 16

1 Answers1

0

Use a fast -preset

Assuming you are using the encoder libx264 for the MP4 output you can use a faster -preset. See FFmpeg Wiki: H.264.

ffmpeg -i left.mp4 -i right.mp4 -filter_complex "[0:v][1:v]hstack=inputs=2:shortest=1[v]; [0:a][1:a]amerge[a]" -map "[v]" -map "[a]" -preset veryfast -ac 2 -shortest -y output.mp4

Not much else you can do as the encoder is already optimized.

Use your player instead

screenshot of side by side video in MPV player

If you only need to play the files side-by-side, and don't need an output file, you can have your player do it and avoid any need for encoding. See Multiple side-to-side video streams in one file without transcoding.

llogan
  • 121,796
  • 28
  • 232
  • 243