0

I need to join two webm videos side-by-side, I've been using the following ffmpeg command to join them:

ffmpeg -i /client.webm -i /client2.webm -filter_complex "[0:v][1:v]hstack=inputs=2[v]; [0:a][1:a]amerge[a]" -map "[v]" -map "[a]" -ac 2 /combined.webm

However, I have 2 issues

  1. this doesn't seem to work properly if videos are of different dimensions or durations,
  2. moreover it seems extremely slow and resource-intensive.

I'm eager for any solutions, and I'd love to know if there are any better command-line alternatives.

Sudipta B
  • 51
  • 1
  • 1
    _"This doesn't seem to work properly"_ explain the problem with more useful info if you need it fixing. – VC.One Nov 28 '20 at 11:11

1 Answers1

0

this doesn't seem to work properly if videos are of different dimensions or durations

"doesn't seem to work properly" doesn't really tell us much, but you should be getting an informative error if the heights do not match, such as: Input 1 height 1080 does not match input 0 height 720.

Each input for the hstack filter must have the same height. You can get height with ffprobe. Then use the scale, scale2ref, pad, and/or crop filters to make the heights the same.

As for duration you can use the shortest option in hstack to force termination when the shortest input terminates. Also use the general -shortest option so the audio matches the joined video duration.

Example:

ffmpeg -i /client.webm -i /client2.webm -filter_complex "[0:v]scale=-2:720[v0];[v0][1:v]hstack=inputs=2:shortest=1[v]; [0:a][1:a]amerge[a]" -map "[v]" -map "[a]" -ac 2 -shortest /combined.webm

moreover it seems extremely slow and resource-intensive.

Video encoding is resource intensive.

libvpx-vp9 is a relatively slow encoder. See FFmpeg Wiki: VP9 for some suggestions or use a different encoder.

I'd love to know if there are any better command-line alternatives.

If you only want to watch side-by-side but have no need to actually create a file then just use your player to do it.

See:

llogan
  • 121,796
  • 28
  • 232
  • 243