Rotate a MP4 file, while preserving codec and quality attributes

54,594

Solution 1

There's no way to rotate a video without re-encoding it. So you can only appoximate the size and quality.

I recommend VirtualDub to do the rotation. It's free and fast.

Solution 2

  1. Open Avidemux (free video editing software)
  2. Open your mp4 file.
  3. Choose a "Video Output" other than "Copy" [I chose "Mpeg4 ASP (ff)"]
  4. Choose Video > Filters (or in Windows, press Ctrl+Alt+F)
  5. Double-click "Rotate" to add that filter
  6. Choose 90 degrees
  7. Press "Close" to exit "Video Filter Manager"
  8. Save

(Thanks to @secret for getting me started, but his/her list of steps weren't complete.)

Solution 3

  1. Open Avidemux
  2. Press Ctrl+Alt+F (for Windows)
  3. Select Rotate
  4. Save

Solution 4

If you actually recorded video in landscape mode, but phone erroneously saved in metadata that it is 90 degrees rotated (it happen to me today during helicopter flight) just download ffmpeg and use this command (completely lossless as it just writes new header - metadata):

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

Solution 5

I used Avidemux, a free video editor.

This software allows you to rotate any movie.

In a drop-down list you can select the desired output format (e.g. MP4, AVI, FLV, etc.).

If using the MPEG-4 ASP setting in the video drop-down list, you will have to fiddle around with Quantizer setting (A higher number means reduced file size and less quality).

This tool is great when you capture a movie on your cell phone and want to send the movie to friends!

Share:
54,594
thegate
Author by

thegate

Updated on September 17, 2022

Comments

  • thegate
    thegate almost 2 years

    I need to rotate a MP4 video by 90 degrees. There is software like Free Video Flip and Rotate available that does this but produces an AVI file.

    Do you have any suggestions for a software to produce a MP4 that is in the same quality (and file size) as the original, just 90 degrees rotated? Does not have to be free software ;-)

    • user15507
      user15507 over 10 years
      That utility wouldn't open an mp4 for me.
    • Aldor
      Aldor over 3 years
      This very similar question has a better answer than the below: use exiftool: superuser.com/a/1310590/127024
  • TimothyP
    TimothyP over 11 years
    Easiest method so far!
  • slm
    slm about 11 years
    Your answer sounds suspiciously like an advertisement. Please read the FAQ on these types of posts as answers. If you're going to provide a link to your product at least take the time to show how you would do this in it. At least your answer would have more merit than just a link.
  • George D
    George D about 11 years
    I tried it. First the "stable" version 1.2 - it does not have the Rotate option. The beta 1.2.1b6 does have the option, but it didn't work for me on 1st try and I didn't pursue any further. At least there's nothing to install - just unzip an executable - and it doesn't seem to hae strings (i.e. crapware) attached. It does require a certain version of Quicktime Alternativeto be installed. A link to that is on their site
  • Witiko
    Witiko almost 11 years
    This is actually not true. The MP4 format supports a rotate flag, which informs the player to rotate the video prior to displaying it. The flag can be edited using f.ex. the MP4Box command-line multiplexer.
  • Sterno
    Sterno almost 11 years
    When I save, I end up with a file of the same size which doesn't actually play. This didn't work until I changed "Video Output" from copy to something like Mpeg4 ASP (ff)
  • JYelton
    JYelton over 10 years
    -1 because although the program suggested is helpful, the steps are incomplete.
  • annejode
    annejode about 10 years
    See Ryan's solution for complete steps.
  • Yogurtu
    Yogurtu about 5 years
    I just tested this approach, seems not to lose quality, file size is 0.001% bigger tough, not sure why if this is a header-metadata change only.
  • Yogurtu
    Yogurtu about 5 years
    I used this once in the past, I don´t know what I did, avidemux looks like detected video was rotated automatically, and rotated video by itself :/... now I have another clean installation and does not work that way anymore, and when I select video outputs (tried all possible combinations) it never ends with same file size than the first time... I would love to have a way to say... "format same than origin" and rotate only
  • Momshad Dinuri Alvee
    Momshad Dinuri Alvee over 4 years
    I think my version of VLC is broken because VLC won't rotate anything, even for viewing, let alone saving the rotated file.....
  • Momshad Dinuri Alvee
    Momshad Dinuri Alvee over 4 years
    I experience a 1.3MB decrease in size but the command ran in a couple of seconds, not nearly long enough to transcode anything 3 minutes long. All I can guess is that GoPro has a bunch of extra room in the file that is not actually used. Maybe space pre-allocated for event tags and such.
  • Metal450
    Metal450 about 4 years
    This is NOT necessarily lossless - if the source video has any other streams (i.e. subtitles, etc) they won't be copied. For that you need -map 0. And even with -map 0 & -copy_unknown, it can still screw up some streams it doesn't recognize, i.e. telemetry recorded by GoPros.
  • Joao Coelho
    Joao Coelho over 2 years
    This wasn't working for me, but found this page with a similar solution that worked: ffmpeg -i input.mp4 -map_metadata 0 -metadata:s:v rotate="90" -codec copy output.mp4