Can I get the frame timestamp data from .MOV format video?

I have 5 videos which will be recorded simultaneously in different locations. I am trying to find a way how to read the timestamp data on each frame of the videos in order to synchronise them together, since it is not possible to start capturing the videos all at the same time. The video shows the timestamps on the bottom left corner of each frame (see figure below), so I guess that the data can be found somewhere in the video file (maybe in the metadata?).
Apart from using the timestamp data to synchronise the videos together, I will also use the timestamps to set specific time-points along the timeline of the videos. These timepoints will be used to measure the time that a certain procedures takes to be performed. Ultimately this will lead to an assesment of how these said procedures are improved in order to save money.
I tried googling for methods of how to obtain this data using MATLAB but it was all in vain.
Thanks in advance for your help!

2 Comments

I have the same question. Were you able to find a solution?
Hi Thomas,
I did not manage to get access to the time-stamp data - it seems to be just hard-coded on each frame and it is not referenced anywhere else in the .mov file. I worked my way around it by synchronising the videos manually (using the time-stamp - visually) and then I cropped the videos according to the manual synchronisation of the 5 videos.
I hope this helps.
Regards, Andre

Sign in to comment.

Answers (1)

You could use VideoReader and after each frame you can access the time property. However this will only get you time relative to the beginning of the movie file. MATLAB calls out to external libraries to do the movie decoding. Mostly that ends up invoking operating system provided media routines.

4 Comments

Do you know how would you do that? I've been trying to use CurrentTime for each frame but it returns as a zero for each frame. I'm interested in getting the timestamp for each frame relative to the start of the video so I can run a timeseries analysis for trajectory data.
%% to obtain timestamp for each frame in lice video for timeseries
for i=5:5 %specify video numbers to process, change as necessary
FileBase = ['/Volumes/SeaLiceBackup/5Dec18collection/' num2str(i) '/']; %create file directory for video stream
obj = VideoReader([FileBase, num2str(i) '.MP4']); %video
objinfo = get(obj); %returns video properties for referencing
Duration = obj.Duration %duration of video
for j = 1:Duration %frame number, or to 18,000 frames (10 minutes) @ ~30fps
current_time(j) = obj.CurrentTime;
end
end
After running this code it returns all zeroes for the frames, but if I use
%% to obtain timestamp for each frame in lice video for timeseries
for i=5:5 %specify video numbers to process, change as necessary
FileBase = ['/Volumes/SeaLiceBackup/5Dec18collection/' num2str(i) '/']; %create file directory for video stream
obj = VideoReader([FileBase, num2str(i) '.MP4']); %video
current_time = obj.CurrentTime;
while hasFrame(obj)
readFrame(obj);
get(current_time);
end
end
instead of the second for loop, my version of Matlab doesn't recognize the function at all or cannot display results. I have versions 2013b and 2018a. Any help is much appreciated.
Thanks! :)
Your first set of code is not advancing the frame by using read or readFrame in your for j loop.
readFrame was not introduced until R2014b so you would need to use read() in R2013b.
%% to obtain timestamp for each frame in lice video for timeseries
for i=5:5 %specify video numbers to process, change as necessary
FileBase = ['/Volumes/SeaLiceBackup/5Dec18collection/' num2str(i) '/']; %create file directory for video stream
obj = VideoReader([FileBase, num2str(i) '.MP4']); %video
framecount = 0;
while hasFrame(obj)
readFrame(obj);
framecount = framecount + 1;
current_time(framecount) = obj.CurrentTime;
end
end
Thanks so much, Walter! I really appreciate the help. :)

Sign in to comment.

Asked:

on 25 Mar 2015

Commented:

on 14 Mar 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!