copying AVI files by using Matlab
이전 댓글 표시
Hi everyone
The following two Matlab code (which they do copy new avi files from another)
First one:
- By using VideoWriter
clear all;
close all; %%%%%%%%%%%%%%%%%%%%%%%
[filename pathname] = uigetfile('*.avi','File Selector');
vid = strcat(pathname, filename);
obj = mmreader(vid);
vid = read(obj);
Frames = obj.NumberOfFrames;
new10=VideoWriter('output10.avi');
for x = 1 : Frames
blocks{x}=vid(:,:,:,x);
end
open(new10);
for f=1:1
ss=im2frame(blocks{f});
writeVideo(new10,ss);
end
close(new10);
msgbox('end of operation','Message','warn');
Second one:
- By using avifile
close all
clear all
[filename pathname] = uigetfile('*.avi','File Selector');
vid = strcat(pathname, filename);
obj = mmreader(vid);
vid = read(obj);
frames = obj.NumberOfFrames;
%%
new10=avifile('output10.avi','compression','None');
for x = 1 : frames
a=vid(:,:,:,x);
blocks{x}=a;
end
%%
for f=1:frames
new10=add frame(new10,blocks{f});
end
new10=close(new10);
msgbox('end of operation','Message','warn');
After running the first one program the new avi file is different from the original file (the pixels of frames are different).
While, after running the first one program the new avi file is same asthe original file (the pixels of
frames are similar).
Please inform me the reason
Best regards
Majid
댓글 수: 4
Image Analyst
2017년 12월 17일
In short, highlight your code, and click the {}Code button.
Jan
2017년 12월 17일
@Majid Al-Sirafi: Image Analyst is right: Your code is really hard to read. Please remove the empty lines and use the "{} Code" button. You will see that it inserts two leading spaces and an empty line before and after the code. Finally it will not hurt anymore to read the code.
Omit the darn clear all. There is no benefit in removing all loaded functions from the memory and waste time with reloading them from the slow hard disk.
What differences do you observe? Are the pixels completely different, or might it be a problem of the color map or a rounding effect? Does the compression play a role?
Majid Al-Sirafi
2017년 12월 17일
Majid Al-Sirafi
2017년 12월 17일
답변 (1개)
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!