Video not playing smoothly

4 ビュー (過去 30 日間)
Sanik
Sanik 2016 年 7 月 25 日
コメント済み: Sanik 2016 年 7 月 25 日
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);

回答 (1 件)

Walter Roberson
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 件のコメント
Walter Roberson
Walter Roberson 2016 年 7 月 25 日
Sanik
Sanik 2016 年 7 月 25 日
still the output video is not playing properly

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

Community Treasure Hunt

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

Start Hunting!

Translated by