Hi,
As per my understanding you want to match the original camera frame rate and duration in MATLAB, one of the possible workaround for this involves manually setting the frame rate and processing the video frame by frame.
Please refer to the example below using MATLAB's "VideoReader" and "VideoWriter" classes:
Create a "VideoReader" object and read the metadata to detect the correct frame rate.
% Create a VideoReader object to read the video file
v = VideoReader('your_video_file.mp4');
% Display original video file frame rate
disp(['Original File Frame Rate: ', num2str(v.FrameRate)]);
Given the original video is expected to have been recorded at 250 fps, process the video frame-by-frame and write it to a new file with the given frame rate using "VideoWriter":
% Create a VideoWriter object to write the video with the correct frame rate
outputVideo = VideoWriter('corrected_video.mp4', 'MPEG-4');
outputVideo.FrameRate = 250; % Set the correct frame rate
open(outputVideo);
while hasFrame(v)
frame = readFrame(v);
writeVideo(outputVideo, frame);
end
close(outputVideo);
% Create a VideoReader object for the corrected video
correctedVideo = VideoReader('corrected_video.mp4');
% Calculate the expected duration and frame count
expectedDuration = 2.5; % seconds
expectedFrameCount = expectedDuration * outputVideo.FrameRate;
% Display the results
disp(['Corrected Video Frame Rate: ', num2str(correctedVideo.FrameRate)]);
disp(['Corrected Video Duration: ', num2str(correctedVideo.Duration)]);
disp(['Expected Frame Count: ', num2str(expectedFrameCount)]);
disp(['Actual Frame Count: ', num2str(correctedVideo.Duration * correctedVideo.FrameRate)]);
Please refer to the MathWorks Documentation for further understanding:
Hope this helps!