Video not playing smoothly
Mostra commenti meno recenti
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);
Risposte (1)
Walter Roberson
il 25 Lug 2016
0 voti
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.
Categorie
Scopri di più su Audio and Video Data in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!