MATLAB Answers

I am making a video at 240 FPS for 1 min but whenever I trim that video for 5 seconds that 5 second of video have 30 FPS. wondering why frame rate reduces?

3 ビュー (過去 30 日間)
Hi,
Is there a way in matlab to trim a clip from a video with the same frame rate. Currently, I am trimming a video and Frame/second reduces to 30 from 240.
Thank you in advance for the reply.

  0 件のコメント

サインインしてコメントする。

採用された回答

Nitin Kapgate
Nitin Kapgate 2020 年 8 月 13 日
The key to the solution of your problem is the “FrameRate” property of the “VideoWriter” object. If unspecified, the “FrameRate” property defaults to a value of 30 FPS. Hence the video output in your case is at 30 FPS. To change the output frame rate to 240 FPS, you need to explicitly set the “FrameRate” property to 240 FPS. The following code snippet can help you to solve your problem.
% Read the input video file
reader = VideoReader("inputVideo.avi"); % Assuming the name of Input video file is "inputVideo.avi".
% Create a VideoWriter object for the output file
writer = VideoWriter('outputVideo.avi'); % Assuming the name of Input video file is "outputVideo.avi".
% If the value of frame rate is unspecified, the FrameRate property is by default set to 30 FPS
% To Set the desired frame rate, explicitly specify the FrameRate property of the VideoWriter object.
writer.FrameRate = 240; % 240 FPS
% Open the file for writing
open(writer);
while hasFrame(reader) % while frames are remaining
img = readFrame(reader); % read a frame
writeVideo(writer,img); % write a frame to the output file
end
% close the files
close(writer);
close(reader);

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by