0

I want to make a horizontal video get converted to vertical video using FFMPEG for automation purposes. I tried with this, which works for vertical to horizontal

    ffmpeg -i input.mp4 \
  -vf 'split[original][copy];[copy]scale=ih*16/9:-1,crop=h=iw*9/16,gblur=sigma=20[blurred];[blurred][original]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2' \
  output.mp4

And tried to change the "16/9" and "9/16" parameters backwards so it makes the reverse procedure, but i get an error.

I don't really need the blur thing, because i want to put some images on the black boxes that will result from doing this process.

2 Answers 2

2

For the blur effect command, you needed to swap a few widths with heights then rescale it so the original video fits in properly above the blurred video:

ffmpeg -i input.mp4 -vf 'split[original][copy];[copy]scale=-1:ih*(16/9)*(16/9),crop=w=ih*9/16,gblur=sigma=20[blurred];[blurred][original]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2' output.mp4

If you want black bars instead, it was covered in this post, but for the tl;dr, it's this:

ffmpeg -i input.mp4 -vf "pad=iw:2*trunc(iw*16/18):(ow-iw)/2:(oh-ih)/2,setsar=1" -c:a copy output.mp4
0

To rotate, you can just edit the video metadata. For example the following command produce output that is shown 90 degree rotated in VLC, you may use -90, depending on orientetion of your video.

ffmpeg -i input.mp4 -metadata:s:v rotate=90 output.mp4

I don't know but if the player is inept to read and apply this, it mightn't work.

Your Answer

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

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