View Full Version : ffmpeg - rotate mov video 90° clockwise?
varekai
3rd November 2017, 22:20
I couldn't find an ffmpeg thread so I'll post my question here.
If there is a thread for ffmpeg I'll edit this post and move it there.
Here goes...
I have some 1280x720 iPhone 6 mov videos I'm trying the rotate 90° clockwise.
iPhone is not getting the format rotation right, you'll never know how it will end up!
I hate Quicktime, used to have it installed but refuse to install it again.
The ffmpeg settings below works alright but the bitrate gets very low and the aspect ratio is way off.
I would like to keep the quality as close as possible.
This is what works for getting the rotation right from 1280x720 to 720x1280:
ffmpeg -i input.mov -c:a copy output.mov
What do I need to add for keeping the rest of the input file intact? Is it possible to do with ffmpeg?
I've searched high and low and tested more than a dozen different rotation ffmpeg settings and they all come out wrong.
Except for the one above but it doesn't get it all right unfortunally.
Any help would be highly appreciated!
Thanks...
See these MediaInfo png's for input and output:
Input:
https://s1.postimg.org/4ox00ckalb/input.png
Output:
https://s1.postimg.org/1x9wga5c3j/output.png
microchip8
4th November 2017, 09:37
use -vf transpose=1
sneaker_ger
4th November 2017, 10:19
If you need to use the transpose filter (because your player doesn't obey simple rotation flags) then ffmpeg will completely re-encode the video. It doesn't really try to make it exactly as the source. If you want higher quality you need to lower -crf (or increase -b:v ).
https://trac.ffmpeg.org/wiki/Encode/H.264
https://trac.ffmpeg.org/wiki/Encode/H.265
varekai
4th November 2017, 12:43
Thanks for replying! Appreciate that!
Let me try to explain and I'm sorry for not giving the right conditions...
The input.mov is right in the sense it's showing the person in the movie upright but streched like "fat and short".
You guys got me thinking... perhaps I'm not having the right approach?
Maybe it's only the aspect ratio 1280x720 that is the culprit?
I have tried this before and it doesn't work.
ffmpeg -i input.mov -vf transpose=1 output.mov
It shows the person right "slim and tall" but tilted 90° clockwise, and size is about 7.8MB and bitrate a lot lower, 2455kb/s.
This works but not correct all the way? It's almost exactly the same 32.9mb size and same bitrate 10.7mb/s.
ffmpeg -i input.mov -aspect 720:1280 -c copy output.mov
It plays fine with right "slim and tall" 720:1280 AR but in preview it's still shows 1280x720 and is tilted 90° clockwise.
Also aspect ratio looks strange 0.562?
This is cut from MediaInfo on file output.mov
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Baseline@L3.1
Format settings : 1 Ref Frames
Format settings, CABAC : No
Format settings, RefFrames : 1 frame
Format settings, GOP : M=1, N=30
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 25 s 679 ms
Bit rate : 10.7 Mb/s
Width : 1 280 pixels
Height : 720 pixels
This looks strange --> Display aspect ratio : 0.562
Original display aspect ratio : 16:9
Rotation : 90°
Frame rate mode : Variable
Frame rate : 30.000 FPS
Minimum frame rate : 30.000 FPS
Maximum frame rate : 31.579 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.386
Stream size : 32.7 MiB (99%)
Language : English
Color range : Limited
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709
sneaker_ger
4th November 2017, 13:34
I have some 1280x720 iPhone 6 mov videos I'm trying the rotate 90° clockwise.
I have tried this before and it doesn't work.
ffmpeg -i input.mov -vf transpose=1 output.mov
It shows the person right "slim and tall" but tilted 90° clockwise
So do you or do you not want to rotate the picture? :confused:
What is (full text) MediaInfo of input file?
0.562 ~= 9/16, i.e. the inverse of the common 16/9. So maybe it's players fault for wrongfully applying AR before/after rotation. Or file is wrong. Either way it could be fixed by re-encoding to non-rotated file with 1:1 sar. Maybe you can upload the actual sample?
varekai
4th November 2017, 13:42
Sorry, but I had the wrong approach, I apologize.
It looks like that a aspect ratio correction is what I need.
MPC-HC plays input.mov correct "slim and tall" but tilted 90° counter clockwise.
MPC-HC plays output.mov upright like PotPlayer but "fat and short" tilted 90° counter clockwise.
I'm so confused right now! :confused::confused::confused:
From PotPlayer:
input.mov (fat and short)
https://s1.postimg.org/3fw4ab8grj/input.png
output.mov (slim and tall)
https://s1.postimg.org/1v6daucz1b/output.png
Cut from MediaInfo
General
Complete name : input.mov
Format : MPEG-4
Format profile : QuickTime
Codec ID : qt 0000.00 (qt )
File size : 33.0 MiB
Duration : 25 s 678 ms
Overall bit rate mode : Variable
Overall bit rate : 10.8 Mb/s
Encoded date : UTC 2017-10-10 16:03:04
Tagged date : UTC 2017-10-10 16:03:30
Writing library : Apple QuickTime
com.apple.quicktime.location.
com.apple.quicktime.make : Apple
com.apple.quicktime.model : iPhone 6
com.apple.quicktime.software : 10.2.1
com.apple.quicktime.creationdate :
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Baseline@L3.1
Format settings : 1 Ref Frames
Format settings, CABAC : No
Format settings, RefFrames : 1 frame
Format settings, GOP : M=1, N=30
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 25 s 678 ms
Bit rate : 10.7 Mb/s
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16:9
Rotation : 90°
Frame rate mode : Variable
Frame rate : 30.000 FPS
Minimum frame rate : 30.000 FPS
Maximum frame rate : 31.579 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.386
Stream size : 32.7 MiB (99%)
Title : Core Media Video
Encoded date : UTC 2017-10-10 16:03:04
Tagged date : UTC 2017-10-10 16:03:30
Color range : Limited
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709
Audio
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : LC
Codec ID : mp4a-40-2
Duration : 25 s 678 ms
Source duration : 25 s 728 ms
Bit rate mode : Variable
Bit rate : 86.5 kb/s
Channel(s) : 1 channel
Channel positions : Front: C
Sampling rate : 44.1 kHz
Frame rate : 43.066 FPS (1024 SPF)
Compression mode : Lossy
Stream size : 271 KiB (1%)
Source stream size : 271 KiB (1%)
Title : Core Media Audio
Encoded date : UTC 2017-10-10 16:03:04
Tagged date : UTC 2017-10-10 16:03:30
Other #1
Type : meta
Duration : 25 s 678 ms
Bit rate mode : VBR
Other #2
Type : meta
Duration : 25 s 678 ms
Bit rate mode : CBR
smok3
5th November 2017, 11:35
Not sure what's the issue, but I have used this in the past
ffmpeg -i wrong.mp4 -c copy -metadata:s:v:0 rotate=0 right.mp4
where rotate is an absolute value.
varekai
5th November 2017, 11:47
Not sure what's the issue, but I have used this in the past
ffmpeg -i wrong.mp4 -c copy -metadata:s:v:0 rotate=0 right.mp4
where rotate is an absolute value.
Thanks for replying!
I believe the issue is about wrong aspect ratio.
Regards
StainlessS
5th November 2017, 16:31
Here a 14MB mp4 for comparison,:- http://www.mediafire.com/file/70yq7f8ar714gut/AR_EFFECT_20171102133314.mp4
General
Complete name : C:\T\AR_EFFECT_20171102133314.mp4
Format : MPEG-4
Format profile : Base Media / Version 2
Codec ID : mp42 (isom/mp42)
File size : 14.6 MiB
Duration : 10 s 702 ms
Overall bit rate : 11.5 Mb/s
Encoded date : UTC 2017-11-02 13:33:25
Tagged date : UTC 2017-11-02 13:33:25
com.android.version : 6.0.1
Video
ID : 2
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Baseline@L3.1
Format settings, CABAC : No
Format settings, ReFrames : 1 frame
Format settings, GOP : M=1, N=30
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 10 s 702 ms
Bit rate : 11.4 Mb/s
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16:9
Rotation : 90°
Frame rate mode : Variable
Frame rate : 25.602 FPS
Minimum frame rate : 5.888 FPS
Maximum frame rate : 34.130 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.484
Stream size : 14.6 MiB (100%)
Title : VideoHandle
Language : English
Encoded date : UTC 2017-11-02 13:33:25
Tagged date : UTC 2017-11-02 13:33:25
Audio
ID : 1
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : LC
Codec ID : 40
Duration : 10 s 664 ms
Bit rate mode : Constant
Bit rate : 38.7 kb/s
Nominal bit rate : 96.0 kb/s
Channel(s) : 1 channel
Channel positions : Front: C
Sampling rate : 22.05 kHz
Frame rate : 21.533 FPS (1024 spf)
Compression mode : Lossy
Stream size : 50.4 KiB (0%)
Title : SoundHandle
Language : English
Encoded date : UTC 2017-11-02 13:33:25
Tagged date : UTC 2017-11-02 13:33:25
varekai
6th November 2017, 10:29
Haha... That's exactly how the input.mov looks like, but without the clowns & beers & basketball... :D
sneaker_ger
6th November 2017, 12:42
Can you try
ffmpeg -i input.mov -vf null -c:a copy output.mov
?
varekai
6th November 2017, 14:43
Thanks!
This works OK! But video is unfortunately compressed to a lower bitrate; 2452kb/s.
sneaker_ger
6th November 2017, 14:46
Like said: you need lower -crf for higher quality.
ffmpeg -i input.mov -vf null -c:v libx264 -crf 18 -c:a copy output.mov
https://trac.ffmpeg.org/wiki/Encode/H.264
varekai
6th November 2017, 15:18
Like said: you need lower -crf for higher quality.
ffmpeg -i input.mov -vf null -c:v libx264 -crf 18 -c:a copy output.mov
https://trac.ffmpeg.org/wiki/Encode/H.264
Ahh, I forgot...
I get this message:
Past duration 0.649986 too large 17152kB time=00:00:25.65 bitrate=5476.2kbits/s speed=1.65x
Doesn' look like an error though.
Thanks all for sorting things out for me in my efforts to use ffmpeg.
Learned at lot, more to learn, lots of fun! :D
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.