mlt

MLT messing up the orientation of video


MLT is automatically changing the orientation of a portrait video to landscape. Is there a way to prevent it?


Solution

  • The real problem is that it is NOT auto-rotating your video. On a smartphone, the video is actually recorded in landscape mode, and then it sets metadata in the file to describe the orientation. If software does not read this and apply some transformation to rotate the video, then it appears incorrect. FFmpeg and then MLT only recently started to support this metadata and automatically do transformations. Obviously, FFmpeg came first, but it took a while for MLT, which only recently added support for it as of v6.2.0. If you have that version and built against recent enough FFmpeg, then it will work automatically. If you run melt some-video -consumer xml then you will see some metadata like

    <property name="meta.media.0.codec.rotate">90</property>
    

    In case you want to prevent automatic orientation, set the autorotate property to 0:

    melt myvideo autorotate=0