Norfeldt
Norfeldt

Reputation: 9688

Python: Find record time of .mp4 movie

I have a MS windows phone that records decent videos in .mp4 format. Looking in the gallery (film roll) all pictures and videos are arrange in the order they were taken.

In python I have been succesfull to find the "date taken" of the photos (using the exifread module), but been out of luck with the videos.

Does anybody know how to get this information via python?

I recorded a 3 second sample [Date: 2014/01/31] ( download it here ) in case someone wants to look at the file format.

Upvotes: 2

Views: 7737

Answers (2)

BringMyCakeBack
BringMyCakeBack

Reputation: 1557

It's not native Python, but you could invoke Atomic Parsley via a system call and then parse the results. Alternatively, there are pretty good python libraries for reading metadata from other multimedia formats, like hachoir. Mpeg-4 is noticeably missing from hachoir's list of supported formats, but it might be possible to adapt its functionality for mp4-derived formats like MOV.

Upvotes: 1

Multimedia Mike
Multimedia Mike

Reputation: 13256

Thanks for the sample. I looked at it and discovered that, unfortunately, it was written with no timestamp data.

In the moov atom, there is an mvhd atom. This has both a creation and modification timestamp. These are both 0, which is why my tool from the other question reports January 1, 1904 for each (start of the QuickTime epoch). Digging deeper into the moov atom, there are 2 trak atoms (1 for video and 1 for audio). Both of these have tkhd atoms which also contain creation and modification timestamps... which, as you might have guessed, are also 0 for this sample.

There are a few different metadata formats you find with these types of files. Regrettably, I don't see any sign of these or any other custom metadata in the short moov atom.

You indicated that the phone is able to display the media in the order in which is was created. It must be using timestamp data that is not stored in this file (e.g., using timestamps as stored in the phone's filesystem). You might need to figure out how to access that data in order to get the true creation timestamps since this software chooses not to write them into the files themselves.

Upvotes: 2

Related Questions