videoWriter videoReader disorts file on linux

2 次查看(过去 30 天)
Matlab R2011a on Ubuntu with latest version of gstreamer 0.10
Basically my code uses videoReader to read in video frames then pads alternate lines of the video with a few pixels to improve the interlacing. I then write the new video out with videoWriter. The code seems to work perfectly under Windows however when I run it on my linux machine the output file is distorted. I have uploaded examples of input http://dl.dropbox.com/u/91060467/input.avi and output http://dl.dropbox.com/u/91060467/output.avi videos to dropbox. Code is reproduced below.
Thanks
if true
function paddingTest(filename,iPad)
[pathstr, name, ext] = fileparts(filename);
mov=VideoReader([pathstr filesep name ext]);
nFrames=mov.NumberOfFrames;
vidHeight=mov.Height;
vidWidth=mov.Width;
frame_in(vidHeight,vidWidth,3)=uint8(0);
frame_out(mov.Height,mov.Width+iPad,3)=uint8(0);
movie_out(1:mov.NumberOfFrames) = struct('cdata', frame_out,'colormap', []);
for idx_frame=1:mov.NumberOfFrames
frame_in=read(mov,idx_frame);
frame_out(1:2:vidHeight,:,:)=[frame_in(1:2:vidHeight,:,:) uint8(zeros(vidHeight/2,iPad,3))];
frame_out(2:2:vidHeight,:,:)=[uint8(zeros(vidHeight/2,iPad,3)) frame_in(2:2:vidHeight,:,:)];
movie_out(idx_frame).cdata=frame_out;
end
writerObj=VideoWriter([pathstr filesep name '_new' ext],'Uncompressed AVI');
open(writerObj);
writeVideo(writerObj,movie_out);
close(writerObj);
end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by