Apple video rotation... Exif?
-
- User
- Posts: 1
- Joined: Tue Dec 08, 2015 1:20 pm
- Are you a spambot?: no
Apple video rotation... Exif?
Hi,
I'm trying to use getID3 to get the orientation of Apple videos. It seems that if an iPhone user takes a video with the volume buttons up then the video records upside down. Apple then add a tag of some sort which all Apple software reads to rotate the video to make sure it plays the right way up but when a user uploads a video to my site it is actually upside down. I want to find this orientation tag so I can rotate these videos as needed.
At the monent I'm doing this
$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze($filepath);
getid3_lib::CopyTagsToComments($ThisFileInfo);
print_r($ThisFileInfo);
Which is giving me a lot of info but nothing it seems for the orientation. I read somewhere that the orientation is in the exif info but I can't seem to see this either?
If anyone could help point me in the right direction it would be hugely appreciated.
I'm trying to use getID3 to get the orientation of Apple videos. It seems that if an iPhone user takes a video with the volume buttons up then the video records upside down. Apple then add a tag of some sort which all Apple software reads to rotate the video to make sure it plays the right way up but when a user uploads a video to my site it is actually upside down. I want to find this orientation tag so I can rotate these videos as needed.
At the monent I'm doing this
$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze($filepath);
getid3_lib::CopyTagsToComments($ThisFileInfo);
print_r($ThisFileInfo);
Which is giving me a lot of info but nothing it seems for the orientation. I read somewhere that the orientation is in the exif info but I can't seem to see this either?
If anyone could help point me in the right direction it would be hugely appreciated.
-
- getID3() v1 developer
- Posts: 1476
- Joined: Fri May 04, 2001 4:00 pm
- Are you a spambot?: no
- Location: Northern Ontario, Canada
- Contact:
Re: Apple video rotation... Exif?
If I recall correctly, I believe that data is parsed by getID3, but I'm travelling at the moment and don't have access to my test files. If you could supply a very small test file (no more than 1MB, less is better) I'll see if I can take a peek. If you could supply 4 such test videos in all 4 orientations (landscape, portrait, inverse-landscape, inverse-portrait) that would be very helpful for my test-file collection. Length and content doesn't matter, 0:01 long of a blank wall would be fine.
-
- User
- Posts: 4
- Joined: Tue Dec 26, 2017 7:01 am
- Are you a spambot?: no
Re: Apple video rotation... Exif?
Hi James, I'm also looking for a way to get video rotation/orientation. I did a var_dump of the file object after $getID3->analyze($myPath); but there appears to be nothing usable in that info. getID3 is unusable for me unless I can tell how the video is rotated so I must be missing something.
Help much appreciated.
Thanks,
Help much appreciated.
Thanks,
-
- getID3() v1 developer
- Posts: 1476
- Joined: Fri May 04, 2001 4:00 pm
- Are you a spambot?: no
- Location: Northern Ontario, Canada
- Contact:
Re: Apple video rotation... Exif?
Again, please provide a small sample file and I can either tell you where the rotation data is returned, or try to find out why it isn't.
-
- User
- Posts: 4
- Joined: Tue Dec 26, 2017 7:01 am
- Are you a spambot?: no
Re: Apple video rotation... Exif?
Here is a sample video:
https://www.dropbox.com/s/vqyutxay5ywv7 ... e.mp4?dl=0
https://www.dropbox.com/s/vqyutxay5ywv7 ... e.mp4?dl=0
-
- User
- Posts: 4
- Joined: Tue Dec 26, 2017 7:01 am
- Are you a spambot?: no
Re: Apple video rotation... Exif?
As additional details, you'll notice in the above video the width is reported as 960 and height 544, so without the rotation info I can't know it's a vertical video and size my video player accordingly.
-
- getID3() v1 developer
- Posts: 1476
- Joined: Fri May 04, 2001 4:00 pm
- Are you a spambot?: no
- Location: Northern Ontario, Canada
- Contact:
Re: Apple video rotation... Exif?
There does seem to be an unparsed "rcif" frame that contains relevant-looking data:
I'll need some time to find out more about this frame type, I'll post back when I have more info.{"wxcamera":{"model":"LG-H815", "apiLevel":"23", "screen":"1440x2560", "crop":"-1x-1", "preview":"1920x1080", "encoder":"960x544", "rotate":90, "deviceoutfps":273, "recordfps":245, "recordertype":2, "needRotateEachFrame":0, "isNeedRealtimeScale":1, "resolutionLimit":1080, "videoBitrate":1200000, "wait2playtime":827, "useback":1, "presetIndex":-1, "recorderOption":-1}}
-
- getID3() v1 developer
- Posts: 1476
- Joined: Fri May 04, 2001 4:00 pm
- Are you a spambot?: no
- Location: Northern Ontario, Canada
- Contact:
Re: Apple video rotation... Exif?
Based on a single sample file, and without any documentation, those fields are now parsed:
https://github.com/JamesHeinrich/getID3 ... 28478f2f9a
The arrays are parsed into $info[quicktime][camera][dscp] and $info[quicktime][camera][rcif]
The info that's currently interesting to you is in $info[quicktime][camera][rcif][wxcamera][rotate] but as a more universal solution I am also returning it in $info[video][rotate] which will be the universal location to look for if and when I find other ways that rotational data is stored in videos (of any format).
https://github.com/JamesHeinrich/getID3 ... 28478f2f9a
The arrays are parsed into $info[quicktime][camera][dscp] and $info[quicktime][camera][rcif]
The info that's currently interesting to you is in $info[quicktime][camera][rcif][wxcamera][rotate] but as a more universal solution I am also returning it in $info[video][rotate] which will be the universal location to look for if and when I find other ways that rotational data is stored in videos (of any format).
-
- User
- Posts: 4
- Joined: Tue Dec 26, 2017 7:01 am
- Are you a spambot?: no
Re: Apple video rotation... Exif?
That's awesome James, thank you, it's working well.
In case it helps you in any way, that video was recorded using wechat (weixin, the Chinese Whatapp)
Thanks for the speedy help!
In case it helps you in any way, that video was recorded using wechat (weixin, the Chinese Whatapp)
Thanks for the speedy help!
-
- getID3() v1 developer
- Posts: 1476
- Joined: Fri May 04, 2001 4:00 pm
- Are you a spambot?: no
- Location: Northern Ontario, Canada
- Contact:
Re: Apple video rotation... Exif?
I have added a more general-purpose rotation detection in for all quicktime/mp4 videos that uses the matrix values in the moov>trak>tkhd atom. It detects 0/90/180/270 rotation in the two devices I tested with, if anyone has a sample file where the rotation is not correctly detected please let me know.
https://github.com/JamesHeinrich/getID3 ... e7a9f27ce0
https://github.com/JamesHeinrich/getID3 ... e7a9f27ce0