2

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.

Norfeldt
  • 8,272
  • 23
  • 96
  • 152
  • 1
    I just wrote a Python script to extract creation/modification timestamps from .mp4 files in response to a similar question. Does the script solve your problem or do you need something more? http://stackoverflow.com/a/21395803/475067 – Multimedia Mike Jan 28 '14 at 02:44
  • I did write a script myself before posting this question to check if I could use the creation date, but unfortunately it didn't do the trick. – Norfeldt Jan 28 '14 at 21:21
  • What was the specific problem that the script couldn't solve? – Multimedia Mike Jan 29 '14 at 04:07
  • Did you notice that I'm talking about .mp4 and not .mov – Norfeldt Jan 29 '14 at 11:41
  • Yep, they're the same format. MP4 is based on MOV. (Effectively the same format; MP4 has a few things than MOV doesn't have, but that shouldn't matter in this case.) – Multimedia Mike Jan 29 '14 at 16:33
  • @MultimediaMike thank you very much for your time. I'm a newbie when it comes to video formats - so I have uploaded a video sample – Norfeldt Jan 31 '14 at 10:58
  • have you looked at this answer http://stackoverflow.com/questions/3844430/how-to-get-video-duration-in-python-or-django – Matti Lyra Jan 31 '14 at 12:19
  • @MattiLyra I just tried that, and it didn't work (neither the creation or mod date) – Norfeldt Jan 31 '14 at 15:07
  • @Norfeldt, are you interested on a solution based on ffmpeg output? – 72DFBF5B A0DF5BE9 Jan 31 '14 at 19:04
  • Are you sure that kind of information is even available? Look: http://stackoverflow.com/questions/3104641/how-do-i-find-the-date-a-video-avi-mp4-was-actually-recorded – mico Jan 31 '14 at 20:48
  • 1
    The [mutagen library](http://mutagen.readthedocs.org/en/latest/api/mp4.html) supports the .mp4 file format – Azeirah Feb 01 '14 at 00:04

2 Answers2

2

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.

Community
  • 1
  • 1
Multimedia Mike
  • 12,660
  • 5
  • 46
  • 62
  • Thank you very much for your time and help. I also thought that the phone was using the create date (which is overwritten when the movie is "sync"ed to the computer). So I created this question http://stackoverflow.com/questions/21457933/python-navigate-to-portable-devices-directory-windows-7 (since it's not that easy to get to the phones memory) – Norfeldt Feb 02 '14 at 20:09
1

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.

Kim
  • 728
  • 10
  • 20
BringMyCakeBack
  • 1,499
  • 2
  • 12
  • 16