SLAM、OpenCV、Linux、ROS等

Matlab截取一段视频并对原视频画面缩小

2018-12-13  本文已影响0人  一恪slam

背景

最近由于处理数据集的需要,需要截取一段视频,并将其中的视频画面缩小为原图1/4。

代码

%read the video
inputVideo = VideoReader('G:/nordland/spring.mp4');

%set the output video parameter
startFrame = 5000;
endFrame = 5010;
outputvideoName = 'G:/nordland/spring5000_6000.avi';
if(exist(outputvideoName,'file'))
    delete(outputvideoName);
end
outputVideo=VideoWriter(outputvideoName);
outputVideo.FrameRate=inputVideo.FrameRate;

%handle and output the video
open(outputVideo);
for i = startFrame:endFrame
    inputFrame = read(inputVideo,i);
    %resize the origin size to 1/4
    frame = imresize(inputFrame,0.25);
    writeVideo(outputVideo,frame);
end

%close
close(outputVideo);
上一篇下一篇

猜你喜欢

热点阅读