Recently I've started making a few movies in Matlab. This is actually quite easy - for an example see this description from the Matlab documentation. Unfortunately, the movie2avi() function does not apply any compression when writing the movie to file (not in Linux, anyway), and this results in very large movies (on the order of 100 MB for a few seconds).
However, I found a solution. I originally posted it as a reply in the MATLAB Newsreader, but I thought I'd share it here as well:
You can transcode Matlabs AVI movies using FFmpeg (www.ffmpeg.org). If you don't have the package, you can install it using the terminal:
sudo apt-get install ffmpeg
If you have only one file, let's call it inputFile, you can transcode it using something like this:
ffmpeg -i inputFile.avi -sameq outputFile.avi
The "-sameq" option is used to preserve video quality. I tested this on a 80 MB file produced by Matlab, and got a 5 MB file without any visible loss in quality. If you want to do it within your matlab script, use the system() command:
system('ffmpeg -i file1.avi -sameq outputFile.avi')
If you have a problem with the Matlab AVI file growing too big, you can split it into several smaller files and compress them as you go, and finally combine them after your iteration has finished. A way of doing this is described here in the FFmpeg FAQ. Note that you will have to transcode your intermediate files to MPEG format. .
Thursday 13 January 2011
Subscribe to:
Post Comments (Atom)
8 comments:
Awesome!! Works like a charm. My video size went down from 35 MB to below 500KB
sounds like exactly what I need..cant wait to get back in the office and try it out!!
Happy to be of help! :)
Couldn't have been any much more appropriate help than what I needed. Thank you.
2.3G -> 10M. boom. thanks!
An update: it seems the -sameq option has been removed in newer versions of ffmpeg, but you can now use -qscale 0 like this:
ffmpeg -i inputFile.avi -qscale 0 outputFile.avi
I use iDealshare VideoGo to convert and compress AVI video files with this step by step guide from http://www.idealshare.net/video-converter/how-to-compress-avi-files.html
It can easily help:
Compress AVI file without losing too much quality and with or without reencoding;
Compress any video files like MP4, WMV, MKV, MOV, FLV, ASF,
MXF, WebM, OGV, 3GP, 1080p AVCHD, MTS/M2TS, MOD, DivX, Xvid and more;
Compress audio files such as MP3, WAV, M4B, DTS, AC3, AAC, FLAC, ALAC, VOC, M4A, 3GA, AIFF, CAF, and QCP;
Convert any video to popular video or audio or convert any audio to audio with strong compatibility;
Custom video and audio in these settings: crop, cut, split,
merge, rotate, take snapshot, watermark video, adjust volume and so on
Avdshare Video Converter also works great in compresss AVI, MKV, AVCHD, MOV, MPG, MP3, WAV etc video and audio file size
Here is the easy guide
https://www.avdshare.com/compress-mkv-to-smaller-file-size
Post a Comment