Video not playing smoothly
Show older comments
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);
Answers (1)
Walter Roberson
on 25 Jul 2016
0 votes
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.
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!