ffmpegrotationdebianvideo-encodingavconv

Rotate mp4 videos without re-encoding


I'm looking for a way to rotate videos shot with my Nexus 4 on my Debian Wheezy sytem. The videos are shot in portrait mode and I would like to rotate them to landscape mode. Preferably the rotation is command-line driven.

I have found several previous questions which are hinting at a good solution but I can't seem to manage to get it working.

To begin with there was this question: Rotating videos with FFmpeg

But it indicates that ffmpeg is outdated and that I should use avconv. I found this question detailing the way to go forward. https://askubuntu.com/questions/269429/how-can-i-rotate-video-by-180-degrees-with-avconv

This made me using following command:

avconv -i original.mp4 -vf "transpose=1" -codec:v libx264 -preset slow -crf 25 -codec:a copy flipped.mp4

However, this is painstakingly slow (last test took me more than 6 hours for less than 3 minutes of footage) and does not result in a playable movie. I also get an error in logging output which states Mb Rate > level limit.

Is there an issue here with the re-encoding? Should I first re-encode the videos from my phone to another, more "workable" encoding before applying the rotations? Or am I missing another important point?


Solution

  • If you just want to change the metadata such that mediaplayers that consider the flag play the file rotated, try something like:

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

    as found elsewhere on stackoverflow.