VideoWriter with 4k images

7 ビュー (過去 30 日間)
Maxime Rivard
Maxime Rivard 2017 年 5 月 2 日
編集済み: cr 2020 年 11 月 22 日
Is there any way to use 4k images to make 4k videos with the VideoWriter function? Is outputs an error message saying its maximal resolution if (close to) 1080p. Or any other way to assemble 4k videos from 4k images with matlab? I used the function to create 1080p videos from 1080p images and it worked very well.
Thanks.

採用された回答

Walter Roberson
Walter Roberson 2017 年 5 月 2 日
In R2017a,
obj = VideoWriter('test.avi');
data = rand(4096);
open(obj)
writeVideo(obj,data)
writeVideo(obj,sin(data))
close(obj)
does not give any error message.
If I switch to obj = VideoWriter('test2.mp4', 'MPEG-4') then it allows me to write one frame but for the second one gives the non-specific error,
Error using VideoWriter/writeVideo (line 369)
Could not write a video frame.
  2 件のコメント
Maxime Rivard
Maxime Rivard 2017 年 5 月 2 日
編集済み: Maxime Rivard 2017 年 5 月 2 日
Ok it does work with default .avi but with MPEG-4 I get
Error using VideoWriter/writeVideo (line 369)
Frame must be between 64x64 and 1088x1920
Walter Roberson
Walter Roberson 2017 年 5 月 3 日
Frames that large are not supported by MPEG-4 part 2, so it must be a Par 10 profile. Possibly only up to Level 5 is supported; see https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Levels

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

その他の回答 (1 件)

cr
cr 2020 年 11 月 22 日
編集済み: cr 2020 年 11 月 22 日
I see this error when trying to log live images from a UHD camera using DiskLogger feature in image acquisition toolbox. However, if I use VideoWriter() in the image preview callback it writes the UHD frames to video without error. But when I check the video file the number of frames are about a fifth of what's expected. A file logged for 35mins shows only 7min in video file even though the framerate is set correctly. Strange!
Disklogger method:
vidobj.LoggingMode = 'disk';
vidobj.DiskLogger = VideoWriter('video.mp4','MPEG-4');
vidobj.FramesPerTrigger = Inf;
start(vidobj)
Saving fames in Preview Callback method:
function previewREC_callback(obj,event,himage,handles,v)
try
himage.CData = event.Data;
writeVideo(v,event.Data);
catch err
fprintf(2,'Image Preview/Recording Error: %s\n',err.message);
stoppreview(obj);
close(v);
end

Community Treasure Hunt

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

Start Hunting!

Translated by