【问题标题】:Matlab Code to Convert Video to Sequence of Frames将视频转换为帧序列的 Matlab 代码
【发布时间】:2015-09-10 10:31:37
【问题描述】:

嗨,谁能告诉我我的 Matlab 代码将视频转换为帧序列有什么问题。它不起作用。

clc
clear all
close all

file=aviinfo('test.avi');

frm_cnt=file.NumFrames

FileExtension='.bmp'

h = waitbar(0,'Please wait');

for i=1:frm_cnt

   % Read the Frame of the Video file
   frm(i)=VIDEOREADER ('test1.avi',i);
   % Convert Frame to image file   
   frm_name=frame2im(frm(i));
   %Create Filename to store
   Filename=strcat(strcat(num2str(i)),FileExtension);
   % Write image file  to the current folder
   imwrite(frm_name,Filename);

   waitbar(i/frm_cnt,h)

end
%Close Progress bar
close(h)

【问题讨论】:

  • 怎么不行?你的电脑着火了?您收到错误消息?另外,您只需要定义 1 个VideoReader 对象
  • 确定不想使用 FFMPEG?更好的工具。

标签: matlab frames


【解决方案1】:

试试这个:

    shuttleVideo = VideoReader('shuttle.avi');
    ii = 1;

    while hasFrame(shuttleVideo)
       img = readFrame(shuttleVideo);
       filename = [sprintf('%03d',ii) '.jpg'];
       fullname = fullfile(workingDir,'images',filename);
       imwrite(img,fullname)    % Write out to a JPEG file (img1.jpg, img2.jpg, etc.)
       ii = ii+1;
    end

【讨论】:

  • 非常感谢您,我会试试这个:D
猜你喜欢
  • 1970-01-01
  • 2023-03-04
  • 1970-01-01
  • 1970-01-01
  • 2018-08-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多