"Quality" property of VideoWriter object doesn't do anything. How to get higher quality mp4 video?
Show older comments
I'm trying to encode an animation as a video, using MATLAB 2017b. The frames of my animation are in struct F, which is produced earlier with getframe inside a loop.
The documentation for VideoWriter says, under the quality property,
Video quality, specified as an integer in the range, [0,100]. Higher quality numbers result in higher video quality and larger file sizes. Lower quality numbers result in lower video quality and smaller file sizes.
Quality is available only for objects associated with the MPEG-4 or Motion JPEG AVI profile. After you call open, you cannot change the Quality value.
Fair enough. This is what I'm trying:
V = VideoWriter(myfilename, 'MPEG-4');
V.FrameRate = 5;
V.Quality = 85;
open(V);
writeVideo(V,F);
close(V);
However, regardless of what value I set V.Quality to, it produces exactly the same (heavily compressed) video with exactly the same filesize. This setting seems to be ignored.
Is this a bug? If not, then what am I doing wrong? Either way, how can I produce a higher-quality compressed video? (ideally using mp4/H.264, not M-JPEG etc, as I want it to be widely playable)
Thanks.
1 Comment
Nona nona
on 2 Oct 2019
I'm also trying to encode an animation video by using this.
Accepted Answer
More Answers (3)
Sudeep Das
on 20 Feb 2020
2 votes
I have the same issue, how do I get a 1080p quality video?
2 Comments
Avery Guild-Bingham
on 6 May 2020
figure('units','pixels','position',[0 0 1920 1080])
For me it was a resolution issue. I build the figures at higher resolution and it works
Simon
on 6 May 2020
Bjorn Gustavsson
on 29 Jan 2019
0 votes
It used to be so that movie2avi and VideoWriter didn't bother with the quality setting on Linux-machines - perhaps that's what you're running into. In my opinion the way to produce the movies with the best control on all settings is to write each frame as an image and then use something like mencoder, ffmpeg or some other standalone program to do that. Another problem might be that the frames grabed with getframe were too small - getframe just grabs a pix-map so its quality is sensitive to the physical size of the frame on-screen. Not much help, but maybe something...
HTH
4 Comments
Simon
on 29 Jan 2019
Sagar Shriram Salwe
on 30 Sep 2019
The simplest method to solve this i find out:
Just go to figure created by imagesc
Open file >Export setup and change the size from auto to expected size required.
Suppost 1920x1024 points and save this configuration and again rerun the .m file without closing image.
The expected changes required for high resolution will get obtained after doing this.
Hope this will help
Andrew Davies
on 4 Oct 2019
I didn't find altering the video resoluton changes th eamount of compression used. Increasing the resolution did make things look a bit better, but the high level of compression still produces very poor results.
Simon
on 5 Oct 2019
Andrew Davies
on 4 Oct 2019
0 votes
I have the same issue. The default quality is terrible, which makes the MPEG-4 format unusable for me.
1 Comment
Lucademicus
on 30 Dec 2019
see my answer
Categories
Find more on Video Formats and Interfaces in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!