Rotate an MP4

Started by cruzzell, August 04, 2024, 03:47:50 PM

Previous topic - Next topic

cruzzell

I am trying to write a command line function for exif tool.

basically i have images and video that I can succesfully read the rotaion of. exifftoo.exe -rotation -w txt myfile.mp4 as example.

It reads back as rotaion : 90 which is good. I can then set rotation to 0 using -rotation=0 but this just make sthe image correctly displayed "wrong".

What I want to do is see that it has rotaion data of : 90 and THEN remove it, AND (most importantly) physically rotate it to the proper 90 WITHOUT rewritting more exif data of 90.

Just plain and simple ROTATE it permanently. Can exiftool accomplish this or must I use something else? Bear in mind that I want this all commandline. After completion it will be rotated correctly and have exif rotation data of 0 or nothing.

StarGeek

No. Exiftool can only edit the metadata, in this case, the data the says the video must be rotated to be viewed correctly.

The only way to permanently rotate it would be to re-encode the file with programs such as Handbrake or ffmpeg.

Note that this is a destructive recompress. The resulting video will have some (hopefully only) minor degradation from the original. There is no way to actually rotate a video without recompressing it and losing some quality.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

cruzzell

(The only way to permanently rotate it would be to re-encode the file with programs such as Handbrake or ffmpeg.)

would this be true for image files as well? Exif too can not permanently rotate?

StarGeek

Yes. Exiftool can only edit metadata. It cannot edit the actual image or video data of any file type.

Lossless image types such as PNG and TIFF can be permanently rotated without any loss of quality. Depending upon the dimensions, it might be possible to rotate JPEGs without loss of quality. If the dimensions of the JPEG are divisible by 8 (or sometimes 16), then it can be rotated losslessly. You would want to look for a program that can do lossless JPEG transformations. On Windows, you can use Irfanview if you download the lossless transform plugin. XnView is cross-platform and can also do this.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

stan

Quote from: StarGeek on August 04, 2024, 07:22:24 PMYou would want to look for a program that can do lossless JPEG transformations.
If looking for a command-line utility the official IJG jpegtran would be it.

boinjyboing


Yes, it's more of an ffmpeg feature to work with videos.

Wanted to add that it *is* possible to rotate videos losslessly without re-compression. As one example, I've used this to losslessly rotate mp4 files recorded by my phone:

ffmpeg -i input.mp4 -metadata:s:v rotate=-180 -codec copy output.mkv
(The mkv format is playable by any modern player like vlc.) Ffmpeg experts will have more information about how to rotate videos, though.

StarGeek

Quote from: boinjyboing on August 14, 2024, 12:59:59 PM(The mkv format is playable by any modern player like vlc.)

IIRC, Apple devices don't support MKV natively.

Also, I think that just sets the rotate metadata, the same as what exiftool does, and doesn't actually rotate the video.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype