<p>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):</p>
<pre><code>exiftool -m -P -overwrite_original -api LargeFileSupport=1 -rotation=90 movie.mov
</code></pre>

CC BY-SA 4.0
2024-01-01T18:48:34.990Z
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.
Tyrone Hirt
CC BY-SA 4.0
2024-01-01T19:55:24.073Z
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.
Tyrone Hirt
CC BY-SA 4.0
2024-01-02T13:13:04.783Z
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

https://exiftool.org/forum/index.php?topic=6670.msg46745#msg46745
wywh
CC BY-SA 4.0
2024-01-02T13:54:01.673Z
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?
Tyrone Hirt
CC BY-SA 4.0
2024-01-02T14:22:34.647Z
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. https://exiftool.org/faq.html#Q13
wywh
CC BY-SA 4.0
2024-01-02T19:50:33.260Z
Thank you very much for the explanation and attention. Based on what you explained to me, I believe that XMP would not solve the problem, I need to open the rotated files within Premiere Pro, and I believe that with an external XMP this will not be possible.

Anyway, based on what you taught me and my needs, I created a script that avoids rewriting by directing the ExifTool output to another folder, so I can use the tool to unload my memory card with the videos already rotated.
Tyrone Hirt
CC BY-SA 4.0
2024-01-02T19:51:08.013Z
I created a loop in powershell to execute this command: `& $exiftoolPath -m -P -progress -api LargeFileSupport=1 -rotation=90 -o $outputDirectory $file.FullName -charset filename=cp1252`
Tyrone Hirt
CC BY-SA 4.0
2024-01-02T19:52:49.873Z
But I would still like to understand why `ffmpeg` generates this difference in frames, being able to use it would still be useful for me...
Tyrone Hirt
CC BY-SA 4.0
2024-01-01T14:14:40.647Z
2024-01-01T14:35:28.543Z
2024-01-01T14:35:28.543Z
wywh
<p>I created an FFMpeg script to rotate <code>-90</code> some videos that I record on my Sony A7iii, with the camera vertically, this makes these videos display correctly.</p>
<p>the script is this:</p>
<pre><code>ffmpeg -i input.mp4 -c:v copy -metadata:s:v:0 rotate=-90 output.mp4
</code></pre>
<p>The issue is that for some reason all the output files are having variations of <code>2 frames</code>, which causes me problems when I use these files as Proxy videos in Premiere Pro.</p>
<p>For example, if the original file has a <code>Media Duration</code> (in Premiere Pro) of <code>00:00:32:12</code>, the output file for some reason will have a <code>Media Duration</code> of <code>00:00:32:10</code>.</p>
<p>The files were written in <code>XAVC 4K</code> with <code>23,976 fps</code></p>
<p>How can I fix this problem?</p>
<p>I've already tried adding <code>-r 23.976</code> to the code to force the frame rate, but that didn't help either.</p>
<p>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.</p>
<p><strong>EDIT</strong></p>
<p>I did a test by completely copying the audio and video streams from my original file, the command line looked like this:</p>
<pre><code>ffmpeg -i C2526.MP4 -c:v copy -c:a copy -metadata:s:v:0 rotate=-90 C2526-test.mov
</code></pre>
<p>I know that the <code>.mov</code> output would not return a valid file, since no conversion is being done, but it is necessary because <code>ffmpeg</code> does not accept copying the <code>PCM</code> stream from the camera file to the <code>.mp4</code> container, so after generating it I rename it the extension to <code>.mp4</code> for the file to be valid.</p>
<p>See that this command doesn't change anything other than the video rotation metadata, everything stays exactly the same, and even so the <code>Media Duration</code> has a variation of 2 frames...</p>

<ffmpeg><premiere-pro>
Rotate video without re-encoding - problems
Tyrone Hirt
# Rotate video without re-encoding - problems

(Asked by: username_0 on 2023-12-29)

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.
EDIT
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...

**Tags:** ffmpeg, premiere-pro


---

## 1 answers

### Answer by username_1 on 2024-01-01. Score: 1 | Accepted answer

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

> **Comments:**
> **username_0**: 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.  
> **username_0**: 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.  
> **username_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  https://exiftool.org/forum/index.php?topic=6670.msg46745#msg46745  
> **username_0**: 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?  
> **username_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. https://exiftool.org/faq.html#Q13  
> **username_0**: Thank you very much for the explanation and attention. Based on what you explained to me, I believe that XMP would not solve the problem, I need to open the rotated files within Premiere Pro, and I believe that with an external XMP this will not be possible.  Anyway, based on what you taught me and my needs, I created a script that avoids rewriting by directing the ExifTool output to another folder, so I can use the tool to unload my memory card with the videos already rotated.  
> **username_0**: I created a loop in powershell to execute this command: `& $exiftoolPath -m -P -progress -api LargeFileSupport=1 -rotation=90 -o $outputDirectory $file.FullName -charset filename=cp1252`  
> **username_0**: But I would still like to understand why `ffmpeg` generates this difference in frames, being able to use it would still be useful for me...  

---

