Video not playing smoothly
2 次查看(过去 30 天)
显示 更早的评论
I have this code converting from images to a video. But the problem is, the output video is not playing smoothly. Can anyone figure out the problem please?
baby = VideoReader('baby.avi');
imageNames = dir(fullfile('D:\code_video_watermarking\watermarkframes\','*.jpg'));
imageNames = {imageNames.name}';
outputVideo = VideoWriter(fullfile('D:\code_video_watermarking\','watermarked_video.avi'));
outputVideo.FrameRate = baby.FrameRate;
open(outputVideo);
for i = 1:length(imageNames)
img = imread(fullfile('D:\code_video_watermarking\watermarkframes',imageNames{i}));
img = ycbcr2rgb(img);
writeVideo(outputVideo,img);
end
close(outputVideo);
shuttleavi = VideoReader(fullfile('D:\code_video_watermarking\','watermarked_video.avi'));
ii=1;
while hasFrame(shuttleavi)
mov(ii) = im2frame(readFrame(shuttleavi));
ii = ii+1;
end
f = figure;
f.Position = [150 150 shuttleavi.Width shuttleavi.Height];
ax = gca;
ax.Units = 'pixels';
ax.Position = [0 0 shuttleavi.Width shuttleavi.Height];
image(mov(1).cdata,'Parent',ax);
axis off
movie(mov,1,shuttleavi.FrameRate);
0 个评论
回答(1 个)
Walter Roberson
2016-7-25
You might want to experiment with VideoPlayer, which should be more efficient than movie()
However, movie() can use an existing figure but VideoPlayer needs its own figure.
3 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!