MLT, how to rotate a video 90 degrees and make the resulting height be the same as the original width?

Fabio A. picture Fabio A. · Mar 4, 2015 · Viewed 7.1k times · Source

I shot a video with my phone in portrait orientation (vertically), which now I need to edit to make it fit properly in a landscape (horizontal) layout. When playing it on my computer and in any of the video editors available on linux, it looks like this.

Original

So what I want to do now, first and foremost, is rotate it 90 degrees and make it look like this.

Wanted

Basically, I want the result to be as tall as the width of the original video. Optionally, I want it to be as wide as the height of the original video.

However, what I get is a video which has the same dimensions as the original, without rotation, which therefore gets letter-boxed (black bands on its sides) and has the upper and lower parts cropped, like shown in this picture.

What I get instead

From what I understood, I should play with profiles, however I don't seem to get it right no matter what I do.

I'm fine with letter-box, but I don't want the video cropped, and I don't want to zoom out so that the image fits by losing vertical resolution.

Any help would be appreciated.

Answer

Brian picture Brian · Mar 6, 2015

If you don't mind using ffmpeg, you can do:

ffplay input -vf 'rotate=angle=PI/2:out_w=ih:out_h=iw'

Replace "ffplay" with "ffmpeg" to encode to an output file. Replace "PI/2" with "-PI/2" to rotate counter clockwise.