drewnoakes / metadata-extractor

Extracts Exif, IPTC, XMP, ICC and other metadata from image, video and audio files
Apache License 2.0
2.59k stars 481 forks source link

Can not retrieve mp4 video rotate property in metadata #348

Closed songday closed 6 years ago

songday commented 6 years ago

here's metadata output by ffprobe:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'e:\tt\82_1526629849542.mp4': Metadata: major_brand : mp42 minor_version : 1 compatible_brands: mp41mp42isom creation_time : 2018-05-18T07:50:18.000000Z Duration: 00:00:10.74, start: 0.000000, bitrate: 829 kb/s Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 89 kb/s (default) Metadata: creation_time : 2018-05-18T07:50:18.000000Z handler_name : Core Media Audio Stream #0:1(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, sm pte170m/bt709/bt709, progressive), 480x360, 735 kb/s, 29.98 fps, 29.97 tbr, 600 tbn, 1200 tbc (default) Metadata: rotate : 90 creation_time : 2018-05-18T07:50:18.000000Z handler_name : Core Media Video Side data: displaymatrix: rotation of -90.00 degrees 1.79 A-V: -0.028 fd= 1 aq= 30KB vq= 67KB sq= 0B f=0/0

As we can see, 'rotate : 90' in Metadata section

I uploaded test file here: http://test01.tourting.com/wer/82_1526629849542.mp4

payton commented 6 years ago

We will need to find out which box this metadata is located in (or if it is in a current box that we already parse). I will do some searching myself.

If you find or know any information on this, please post it here.

These are the boxes that we pass, but do not parse:

mdat
tkhd
edts
dinf
stsc
stsz
stco
tkhd
edts
dinf
stss
sdtp
stsc
stsz
stco
udta

It is possible that some of these are containers and may contain other boxes.

http://l.web.umkc.edu/lizhu/teaching/2016sp.video-communication/ref/mp4.pdf

payton commented 6 years ago

This information will be located in the 'meta' box: https://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/QuickTime.html#ItemPropCont

Parsing of the metadata box was implemented in QuickTime, so it just needs to be copied over and adjusted a bit.

payton commented 6 years ago

One more thing...

There is a comment in the exiftool docs mentioning the composite rotation tag: https://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/QuickTime.html#TrackHeader

I'm not sure if this means it is located in that matrix. I've added track header parsing in my local project, but the matrix does not change when rotation changes. The documentation also mentions an 'irot' tag that is supposed to contain the rotation information, but this character combination does not exist in the file when doing a text search.