Many smartphone users record video vertically, holding the phone in front of themselves, up and down. It's not hard to see why: this is the natural way to hold a small, chocolate-bar-shaped object. However, most televisions and computer screens, and most media that plays on them, are oriented horizontally.
In this tutorial you'll learn how to use FFMpeg to convert vertical video into fuzzy-cropped stretched-original-background horizontal video, as seen on YouTube and the TV news, in just one step.
You Will Need
To follow this tutorial, you will need:
- access to the command line
- a video file: this tutorial assumes .mp4 video but .mov works fine too (our example is 'Overpopulated Goldfish' from VideoHive)
Convert Vertical Video to Horizontal
Here's how to convert vertical video to horizontal, 16:9 video:
Load up a Terminal Window
First, open your terminal (Command-T on Mac, Control-T on Linux, BSD, etc., and for Windows folks, I suggest cmder) and navigate to the folder containing the video you want to convert from vertical to horizontal.
Fire Up FFMpeg
Now input the following line, substituting
inputfile.mp4 for the name of your source file and whatever name you'd like for the
outputfile.mp4 file, so long as it ends with the .mp4 suffix and isn't the same name as the input file:
ffmpeg -i inputfile.mp4 -filter_complex '[0:v]scale=ih*16/9:-1,boxblur=luma_radius=min(h\,w)/20:luma_power=1:chroma_radius=min(cw\,ch)/20:chroma_power=1[bg];[bg][0:v]overlay=(W-w)/2:(H-h)/2,crop=h=iw*9/16' outputfile.mp4
And done! Wait for FFMpeg to encode the new video.
At the heart of this technique is the
boxblur FFMpeg filter. You can alter the effect by changing the parameters, and you can additionally use
unsharp. The FFMpeg documentation has a full listing of options.
If your video is a bit shaky, I suggest you do your stabilization on the vertical video before creating the horizontal video. Doing a bit of stabilization before will make for a smoother end result.
And finally: if you're new to the command line, I recommend Kezz Bracey's tutorial series The Command Line for Web Designers, it's an excellent introduction.
- TerminalThe Command Line for Web Design: IntroductionKezz Bracey
- TerminalThe Command Line for Web Design: Grasping the BasicsKezz Bracey
- VideoHow to Stabilize Video in After Effects with ReelSteadyCharles Yeager
- VideoBuilding Your Own DIY Camera Stabilizing RigStefan Surmabojov