Python: Find record time of .mp4 movie

那年仲夏 提交于 2019-12-24 02:17:05

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/21381652/python-find-record-time-of-mp4-movie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!