Try this code. May be this code will help you.
videoPath = 'path_to_video_file';
videoObj = VideoReader(videoPath);
frame = readFrame(videoObj);
frameRate = videoObj.FrameRate;
currentTimeFrames = videoObj.CurrentTime;
currentTimeSeconds = currentTimeFrames / frameRate;
disp(['Current Time (VideoReader): ' num2str(currentTimeSeconds) ' seconds']);
mediaPlayer = VideoReader(videoPath);
mediaPlayerObj = vision.VideoPlayer;
while hasFrame(mediaPlayer)
frame = readFrame(mediaPlayer);
step(mediaPlayerObj, frame);
currentTimeMedia = mediaPlayer.CurrentTime;
disp(['Current Time (Media Player): ' num2str(currentTimeMedia) ' seconds']);
In this code, you first create a VideoReader object using the path to the video file. Then, you read the first frame to obtain the frame rate of the video. The CurrentTime property of the VideoReader object provides the current time in frames. By dividing this value by the frame rate, you can calculate the current time in seconds.
Next, the video file is opened in a media player using the vision.VideoPlayer object. The while loop reads frames from the media player and displays them using the step function. The CurrentTime property of the media player object gives you the current time in seconds.
Both the VideoReader and media player time values are displayed using the disp function for comparison.