1
1
If I use:
ffmpeg -i in.mov -vf "transpose=1" out.mov
all .mov
files are getting rotated, but what I need is to automatically detect just the rotated videos and change orientation for just those videos.
How can I automatically detect the rotation or orientation of the video during upload and rotate if needed, so that all .mov
files play in the correct orientation? How can I get that metadata of current degree rotation of my video?
FFmpeg nowadays autorotates the video i.e. if a rotation tag is present, it applies the filter and resets the tag, So the exercise is moot. – Gyan – 2016-12-05T20:31:16.007
This would be bad practice due to transcoding in the case of remultiplexing a video container file with a video stream that has a rotation flag. It is useful to know exactly what is happening to prevent transcoding. – Alex Folland – 2016-12-05T23:23:41.730
1The autorotate does not effect if the video stream is being copied. That can be done by specifying
-c:v copy
– Gyan – 2016-12-06T05:18:02.980Yes, that's exactly why I said what I said. Copying the stream is ideal. Never transcode to apply a rotation filter. Instead, output a container format that supports rotation tag, like mp4 (mkv doesn't seem to support it; tried recently), and use something like
-c copy -metadata:s:v:0 rotate=90
in the ffmpeg command line. – Alex Folland – 2016-12-12T14:51:14.8101I guess there's some lines crossed here. We don't know if the OP's target players respect the rotation tag. In fact, if they did, there would be no need for the OP to ask the Q. The OP is permanently baking in the correct orientation using the transpose filter. To that end, transcoding is required, and my point is recent ffmpeg versions automatically take care of it. – Gyan – 2016-12-12T15:01:50.340
Instead of assuming, I opted to answer the OP's final question, which was "How can I get that metadata of current degree rotation of my video?". – Alex Folland – 2016-12-12T16:28:32.273
"...in order to rotate the video correctly and only when needed" is the logical appendix given all the text above that question. – Gyan – 2016-12-12T17:38:08.373
1So write your own answer. – Alex Folland – 2016-12-13T01:14:26.840