I get a writeVideo error on a script that previously worked

I am trying to merge two videos. I have previously used this code on 2016b and it ran well. However, it suddenly stopped working. I'd appreciate any tips! I get this error: "Could not write a video frame." in response to this line in my code: writeVideo(outputVideo, imgt);
Here is the full code:
close all clearvars -except SpecificTrial
cd(SpecificTrial)
FirstVideo='GoPro_L_01.MP4'; SecondVideo='GoPro_L_02.MP4'; OutPutVideo='GoPro_L';
vid1 = VideoReader(FirstVideo); vid2 = VideoReader(SecondVideo);
videoPlayer = vision.VideoPlayer; outputVideo = VideoWriter(OutPutVideo); outputVideo.FrameRate = vid1.FrameRate; open(outputVideo);
VideoFrameRate=1/vid1.FrameRate; VideoDuration1=vid1.Duration*vid1.FrameRate; VideoDuration2=vid2.Duration*vid2.FrameRate;
for i=1:VideoDuration1 tf=hasFrame(vid1); if tf==1 img1 = readFrame(vid1); imgt=[img1]; step(videoPlayer, imgt);%play video writeVideo(outputVideo, imgt); %record new video end; end
for i=1:VideoDuration2 tf=hasFrame(vid2); if tf==1 img1 = readFrame(vid2); imgt=[img1]; step(videoPlayer, imgt); writeVideo(outputVideo, imgt); end; end
release(videoPlayer); close(outputVideo);

3 件のコメント

Walter Roberson
Walter Roberson 2018 年 11 月 8 日
編集済み: Walter Roberson 2018 年 11 月 8 日
The open might fail if you do not have write access to the directory.
The write of the frame can fail if you run out of disk space .
Jan
Jan 2018 年 11 月 8 日
The file might be opened from another application also or locked.
Jessica Yorzinski
Jessica Yorzinski 2018 年 11 月 8 日
Lack of disk space was this issue-- thanks so much for the help!

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

回答 (0 件)

製品

リリース

R2016b

タグ

質問済み:

2018 年 11 月 7 日

コメント済み:

2018 年 11 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by