Can I get the frame timestamp data from .MOV format video?
Show older comments
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
Thomas Keady
on 27 Feb 2018
I have the same question. Were you able to find a solution?
Andre
on 27 Feb 2018
Answers (1)
Walter Roberson
on 27 Feb 2018
0 votes
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
Kathryn Liberman
on 13 Mar 2019
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! :)
Walter Roberson
on 13 Mar 2019
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.
Walter Roberson
on 13 Mar 2019
%% 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
Kathryn Liberman
on 14 Mar 2019
Thanks so much, Walter! I really appreciate the help. :)
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!