videowriter mpeg-4 vs avi file size

17 次查看(过去 30 天)
JM
JM 2024-9-30,16:00
回答: Arjun 2024-10-1,9:22
Im using videowriter to display some medical images which are typically about 10mb per frame
The orignal movie was made in AVI and are about 200mb each
vs.
path = ['C:\Users\**\image sets\Jim\03 - Non Clinical 3D Cases\0\']
y = VideoWriter("newfile2.avi","Uncompressed AVI");
y.FrameRate = 3
open(y)
I found out the person doing the presentation has a MAC and the codec is not working
I am thus trying to change it over to MPEG4
Each time I do this the same dataset for the movie comes out less than 1mb
I am using the quality variable
path = ['C:\Users\**\image sets\3D images\ImageData-Reconstructed slices DICOM\mini1\mini1\0\']
y = VideoWriter("newfile4.mp4", 'MPEG-4');
y.FrameRate = 3
y.Quality=100
any help?
thanks
  2 个评论
JM
JM 2024-9-30,16:07
移动:Walter Roberson 2024-9-30,21:59
this is the full code with username removed
clear
path = ['C:\Users\J***\image sets\Jim\03 - ***\0\']
y = VideoWriter("newfile2.avi","Uncompressed AVI");
y.FrameRate = 3
open(y)
for n = 2:19+1
file = ['**', num2str(n) '.DCM'];
im = double(dicomread([path, file]))/2^16;
%im = imcrop(im,[1000,1000,600,600]);
imshow(im);
hold on;
text(100, 100, '*****', 'FontSize', 16, 'Color', 'white');
text(100, 200, '03 - ****\0\', 'FontSize', 16, 'Color', 'white');
text(100, 300, ['ZAxis: ', num2str(n-1), 'mm'], 'FontSize', 16, 'Color', 'white');
F = getframe(gca);
im2 = frame2im(F);
writeVideo(y,im2);
end
close(y)
Walter Roberson
Walter Roberson 2024-9-30,22:01
The file sizes differ, but what problem are you encountering?
You would expect MPEG4 to be smaller than uncompressed AVI.

请先登录,再进行评论。

回答(1 个)

Arjun
Arjun 2024-10-1,9:22
Hi @JM,
I understand that you have generated videos using “videowriter” in MATLAB and you want to understand why the size of videos generated in AVI and MPEG-4 formats so different.
Video formats like AVI are uncompressed formats focussed mainly on the quality aspect of the vide and storage requirements are more for them but video formats like MPEG-4 are more efficient to store and the quality of generated video takes a hit. To enhance the quality of the MPEG-4 video you can set the quality to higher values and if still not satisfied then consider changing the video format.
Hence the behaviour you see is expected and there will be considerable size difference between uncompressed AVI and MPEG-4 format.
I hope the explanation helps!

标签

产品


版本

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by