I created an FFMpeg script to rotate -90 some videos that I record on my Sony A7iii, with the camera vertically, this makes these videos display correctly.

the script is this:

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

The issue is that for some reason all the output files are having variations of 2 frames, which causes me problems when I use these files as Proxy videos in Premiere Pro.

For example, if the original file has a Media Duration (in Premiere Pro) of 00:00:32:12, the output file for some reason will have a Media Duration of 00:00:32:10.

The files were written in XAVC 4K with 23,976 fps

How can I fix this problem?

I've already tried adding -r 23.976 to the code to force the frame rate, but that didn't help either.

The crucial point here is to rotate the video without re-encoding the file, for this reason, I took the approach of changing only the metadata, keeping the video stream untouched, re-encoding will cause a significant time penalty in my workflow.


I did a test by completely copying the audio and video streams from my original file, the command line looked like this:

ffmpeg -i C2526.MP4 -c:v copy -c:a copy -metadata:s:v:0 rotate=-90 C2526-test.mov

I know that the .mov output would not return a valid file, since no conversion is being done, but it is necessary because ffmpeg does not accept copying the PCM stream from the camera file to the .mp4 container, so after generating it I rename it the extension to .mp4 for the file to be valid.

See that this command doesn't change anything other than the video rotation metadata, everything stays exactly the same, and even so the Media Duration has a variation of 2 frames...

1 Answer 1


Losslessly rotate QuickTime mov, mp4 or m4v 90° clockwise (270 CW is the same as -90 CCW. macOS Quick Look can also do the same):

exiftool -m -P -overwrite_original -api LargeFileSupport=1 -rotation=90 movie.mov
  • Wow! This works perfectly, I didn't know the ExifTool tool, thanks for the tip! Do you know exactly how it works? I would mainly like to know if it generates a new file or if it simply changes the metadata of the original file, because if a new file is generated, I believe it could be a negative point for the useful life of the storage devices. I know that FFMPEG necessarily needs to generate a new file. Commented Jan 1 at 18:48
  • I was checking here through CrystalDiskInfo, it seems that the files really need to be rewritten... I believe that this is not very positive considering the useful life of the storage devices, but I think it is the only way... Using ExifTool, the rotation works as expected, I'm not experiencing frame variation, however, for my flow it would still be very interesting to be able to resolve this issue with ffmpeg... if anyone knows a way to fix this "bug" or get around it, I'll still be happy to know. Commented Jan 1 at 19:55
  • 1
    exiftool -ver 10.89 and later edits the MatrixStructure tag of a .mp4, .m4v and .mov QuickTime movie. exiftool always re-writes the file. exiftool -a -G1 -s -n -api LargeFileSupport=1 -MatrixStructure -Rotation movie.mp4 [Track2] MatrixStructure : 1 0 0 0 1 0 0 0 1 [Composite] Rotation : 0 [Track2] MatrixStructure : 0 1 0 -1 0 0 1080 0 1 [Composite] Rotation : 90 exiftool.org/forum/index.php?topic=6670.msg46745#msg46745
    – wywh
    Commented Jan 2 at 13:13
  • As I mentioned, the big problem with rewriting the file every time is the double wear on the storage units, this would reduce the useful life of a storage device by half. Isn't there a way to rotate by changing the metadata without rewriting the entire file? Commented Jan 2 at 13:54
  • 1
    exiftool by design rewrites the whole file when a change has been made to the metadata. Metadata may be restructured in such a way that it takes less space than in the original file, or so that some tags are stored at different offsets in the file. If you worry about wear, use a program that writes to XMP sidecar files. exiftool.org/faq.html#Q13
    – wywh
    Commented Jan 2 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.