Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine start time and end time (seconds since epoch) of video in python?

I have a project that will need to be able to know the time a video file (such as .mp4, .mov, .mxf etc.) was started (e.g. when record was pressed) and when the video file was ended in seconds since epoch.

So far what I have been doing is finding the File Modified time and using that as the endpoint and then subtracting duration to find the beginning. This works pretty well in some cases but it appears that some cameras don't exactly write/modify files in a linear predictable way so sometimes the start/end times of the video files overlap when clearly you can't be recording 2 files at the same time.

Is there some other method or piece of metadata I could access using say ffprobe (or alternative) in python to accurately determine when the video was started and when it was ended?

like image 404
abagshaw Avatar asked Jul 25 '16 00:07

abagshaw


1 Answers

Your best tools are:

ffprobe
mediainfo
exiftool

You can find many types of datestamps in them but I've never tested them for accuracy. If between those tools and filesystem stamps you can't find the proper metadata then you need better tracking at the time of filming. I'm a filmmaker as well as programmer and I can't quite figure out why you would need epoch time but I do know you need better tracking during production.

Try a digital clapboard with a clock, or use a some sort of digital recorder where you can control timestamp creation during recording.

Also, as others have mentioned this question lacks focus. What problem are you trying to solve? I can only think of sync between media sources in which case use some software such as plural eyes.

like image 146
B Rad C Avatar answered Sep 21 '22 20:09

B Rad C