Error using VideoWriter to write video frames to a file

25 ビュー (過去 30 日間)
Jason
Jason 2021 年 3 月 12 日
コメント済み: Jason 2021 年 3 月 12 日
Hello, I am trying to save a video from a FLIR camera using the gentl adaptor.
vid = videoinput('gentl', 1, 'Mono16');
src=getselectedsource(vid);
vid.FramesPerTrigger=20;
preview(vid);
start(vid);
stoppreview(vid);
diskLogger=VideoWriter('D:\Temp\VidMatlab.mp4','MPEG-4'); % Use the MPEG-4 Codec
open(diskLogger);
vid.FramesAvailable
data=getdata(vid,vid.FramesAvailable);
numFrames=size(data,4)
for x=1:numFrames
writeVideo(diskLogger,data(:,:,:,x));
end
close(diskLogger)
But I keep getting the error message
Warning: No video frames were written to this file. The file may be invalid.
Error using VideoWriter/writeVideo (line 414)
Operands to the || and && operators must be convertible to logical scalar values.
  2 件のコメント
Jason
Jason 2021 年 3 月 12 日
OK its this:
if (min(inputFrames(:)) < 0) || (max(inputFrames(:)) > 1)
error(message('MATLAB:audiovideo:VideoWriter:invalidRange', curDataType));
Jason
Jason 2021 年 3 月 12 日
OK I have 2 errors:
1: data=getdata(vid,vid.FramesPerTrigger); rather than data=getdata(vid,vid.FramesAvailable)
2: For video, you must use Mono8

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

採用された回答

Jan
Jan 2021 年 3 月 12 日
Maybe the debugger reveals some details. Type this in the command window:
dbstop if caught error
Then run the code again. If Matlab stops at the error, check which arguments are not scalar in line 414 of videoWriter.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by