ffmpegcropmpv

MPV (FFmpeg) stack 2 videos and then crop output without re-encoding?


I have two 16:9 ratio videos, I want to horizontally stack them, but then crop the resulting video output by about 900px from the right border whilst playing it within mpv and without re-encoding.

Libavfilter does have a crop functionality, but in all examples I've found, the cropping happens before stacking. (Visual representation of what I want to achieve)

I currently have this which somewhat does what I want:

mpv "F:\1.mp4" --external-file="F:\2.mp4" --lavfi-complex="[vid1] scale=1920x1080:flags=spline [vid1_scale]; [vid2] scale=1920x1080:flags=spline [vid2_scale]; [vid1_scale][vid2_scale] hstack [vo]"

Is it possible to crop the video output after stacking?


Solution

  • Add crop immediately after hstack:

    mpv "F:\1.mp4" --external-file="F:\2.mp4" --lavfi-complex="[vid1] scale=1920x1080:flags=spline [vid1_scale]; [vid2] scale=1920x1080:flags=spline [vid2_scale]; [vid1_scale][vid2_scale] hstack,crop=iw-900:ih:0:0 [vo]"
    

    Or crop immediately after one of the scales. Doesn't really matter.