Video not playing smoothly

4 Ansichten (letzte 30 Tage)
Sanik
Sanik am 25 Jul. 2016
Kommentiert: Sanik am 25 Jul. 2016
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);

Antworten (1)

Walter Roberson
Walter Roberson am 25 Jul. 2016
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 Kommentare
Sanik
Sanik am 25 Jul. 2016
still the output video is not playing properly

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by