2

I have seen this and this post explaining how to crop and stack videos using ffmpeg.

My question is - is there an easy (preferably one step) way to turn a horizontally stacked video into a vertically stacked one?

And is there a Linux-way to re-encode given 3D video formats into others?

Edit:

with Mulvyas help I wrote a script which does the converting stuff and creates a text file with meta information needed by the Gear VR video player.

Note: you need a recent version of ffmpeg for the vstack filter - version 2.6 which is installed with Fedora 22 is too old. Version 2.8.3 has vstack available.

1 Answer 1

3

Just integrate all filtering into one command:

ffmpeg -i input.mp4 \
-filter_complex "[0:v]crop=in_w/2:in_h:0:0 [top]; \ 
[0:v]crop=in_w/2:in_h:in_w/2:0[bottom]; \
[top][bottom]vstack[outv]" \
-map "[outv]" -map 0:a -c:a copy output_3dv.mp4

Edit: this command below scales and pads the output to 2000x2000

ffmpeg -i input.mp4 \
-filter_complex "[0:v]crop=in_w/2:in_h:0:0 [top]; \
[0:v]crop=in_w/2:in_h:in_w/2:0[bottom]; \
[top][bottom]vstack,\
scale=iw*min(2000/iw\,2000/ih):ih*min(2000/iw\,2000/ih), \
pad=2000:2000:(ow-iw)/2:(oh-ih)/2[outv]" \
-map "[outv]" -map 0:a -c:a copy output_3dv.mp4
6
  • I have a source video named input.mp4 which I first turn into left.mp4 and right.mp4. If I understand your command assumes these files to exist in the first place.
    – frans
    Commented Dec 12, 2015 at 14:59
  • modified for single input
    – Gyan
    Commented Dec 12, 2015 at 15:08
  • can you scale and pad the output at the same time, too?
    – frans
    Commented Dec 12, 2015 at 16:47
  • sure. what do you want done?
    – Gyan
    Commented Dec 12, 2015 at 17:00
  • I'd want to pad the output to be squared (same width as height). Currently I'm running -vf "pad=width=in_h:height=in_h:x=in_w/2:y=0:color=black" on the output. And additionally I'd like to have a fixed width (and height) of e.g. 2000 pixel
    – frans
    Commented Dec 12, 2015 at 17:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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