Thread Subject: Compression of videos in OSX

Subject: Compression of videos in OSX

From: Andrea Tagliasacchi

Date: 13 Jun, 2008 23:19:02

Message: 1 of 6

If you read the help for avifile you can get the following:

"COMPRESSION - A string indicating the compressor to use.
On UNIX, this value must be 'None'. Valid values for this
parameter on Windows are 'Indeo3', 'Indeo5', 'Cinepak',
'MSVC', 'RLE' or 'None'. To use a custom compressor, the
value can be the four character code as specified by the
codec documentation. An error will result during the call to
ADDFRAME if it can not find the specified custom compressor.
   This parameter must be set before using ADDFRAME. The
default is 'Indeo5' on Windows and 'None' on UNIX."

Is there a compressor available for OSX?
Maybe OSX is considered as unix but it seems there is some
sort of flexibility in the coded specification.

Thanks,
Andrea

Subject: Compression of videos in OSX

From: Dave Tarkowski

Date: 16 Jun, 2008 13:28:59

Message: 2 of 6

Andrea Tagliasacchi wrote:
> If you read the help for avifile you can get the following:
>
> "COMPRESSION - A string indicating the compressor to use.
> On UNIX, this value must be 'None'. Valid values for this
> parameter on Windows are 'Indeo3', 'Indeo5', 'Cinepak',
> 'MSVC', 'RLE' or 'None'. To use a custom compressor, the
> value can be the four character code as specified by the
> codec documentation. An error will result during the call to
> ADDFRAME if it can not find the specified custom compressor.
> This parameter must be set before using ADDFRAME. The
> default is 'Indeo5' on Windows and 'None' on UNIX."
>
> Is there a compressor available for OSX?
> Maybe OSX is considered as unix but it seems there is some
> sort of flexibility in the coded specification.
>
> Thanks,
> Andrea

Andrea,

There is no compression of avi files on OSX at this time. We've updated
the documentation to be more clear on that point. Currently AVIFILE
only allows compression on Windows. Non-Windows platforms can only
write uncompressed AVIs.

-Dave

Subject: Compression of videos in OSX

From: Andrea Tagliasacchi

Date: 16 Jun, 2008 18:38:03

Message: 3 of 6

I found a way of solving the problem.

aviobj = avifile('tempoutput.avi','fps', FPS);
...... % frame recording in here
aviobj = close(aviobj);
    
%%% compress the video (or at least try)
disp('please wait, compressing avi file....');
command = sprintf('mencoder tempoutput.avi -ovc lavc -o %s',
'output.avi');
[STATUSVAR,STATUSMESSAGE] = unix(command);
delete('tempoutput.avi'); % remove temp file
    
if STATUSVAR ~= 0
   error( STATUSMESSAGE );
else
   disp('compression completed');
end

Basically I use mencoder which is the very popular free
encoder. Works really nicely!! From 100MB for 10 seconds
video I got down to 800kB

Cheers, Andrea


Dave Tarkowski <dave.tarkowski@mathworks.com> wrote in
message <g35pqr$n8u$2@fred.mathworks.com>...
> Andrea Tagliasacchi wrote:
> > If you read the help for avifile you can get the following:
> >
> > "COMPRESSION - A string indicating the compressor to use.
> > On UNIX, this value must be 'None'. Valid values for this
> > parameter on Windows are 'Indeo3', 'Indeo5', 'Cinepak',
> > 'MSVC', 'RLE' or 'None'. To use a custom compressor, the
> > value can be the four character code as specified by the
> > codec documentation. An error will result during the call to
> > ADDFRAME if it can not find the specified custom compressor.
> > This parameter must be set before using ADDFRAME. The
> > default is 'Indeo5' on Windows and 'None' on UNIX."
> >
> > Is there a compressor available for OSX?
> > Maybe OSX is considered as unix but it seems there is some
> > sort of flexibility in the coded specification.
> >
> > Thanks,
> > Andrea
>
> Andrea,
>
> There is no compression of avi files on OSX at this time.
 We've updated
> the documentation to be more clear on that point.
Currently AVIFILE
> only allows compression on Windows. Non-Windows platforms
can only
> write uncompressed AVIs.
>
> -Dave

Subject: Compression of videos in OSX

From: Ken Prager

Date: 17 Jun, 2008 11:53:46

Message: 4 of 6

But then you can't view the avi from within Matlab, correct?

Also, I wouldn't delete the temporary file unless I'd confirmed there
were no errors. That is:

if STATUSVAR ~= 0
   error( STATUSMESSAGE );
else
   disp('compression completed');
   delete('tempoutput.avi'); % remove temp file
end



- Ken P.



 "Andrea Tagliasacchi" <ata2@nospam.cs.sfu.ca> wrote:

> I found a way of solving the problem.
>
> aviobj = avifile('tempoutput.avi','fps', FPS);
> ...... % frame recording in here
> aviobj = close(aviobj);
>
> %%% compress the video (or at least try)
> disp('please wait, compressing avi file....');
> command = sprintf('mencoder tempoutput.avi -ovc lavc -o %s',
> 'output.avi');
> [STATUSVAR,STATUSMESSAGE] = unix(command);
> delete('tempoutput.avi'); % remove temp file
>
> if STATUSVAR ~= 0
> error( STATUSMESSAGE );
> else
> disp('compression completed');
> end
>
> Basically I use mencoder which is the very popular free
> encoder. Works really nicely!! From 100MB for 10 seconds
> video I got down to 800kB
>
> Cheers, Andrea
>
>
> Dave Tarkowski <dave.tarkowski@mathworks.com> wrote in
> message <g35pqr$n8u$2@fred.mathworks.com>...
> > Andrea Tagliasacchi wrote:
> > > If you read the help for avifile you can get the following:
> > >
> > > "COMPRESSION - A string indicating the compressor to use.
> > > On UNIX, this value must be 'None'. Valid values for this
> > > parameter on Windows are 'Indeo3', 'Indeo5', 'Cinepak',
> > > 'MSVC', 'RLE' or 'None'. To use a custom compressor, the
> > > value can be the four character code as specified by the
> > > codec documentation. An error will result during the call to
> > > ADDFRAME if it can not find the specified custom compressor.
> > > This parameter must be set before using ADDFRAME. The
> > > default is 'Indeo5' on Windows and 'None' on UNIX."
> > >
> > > Is there a compressor available for OSX?
> > > Maybe OSX is considered as unix but it seems there is some
> > > sort of flexibility in the coded specification.
> > >
> > > Thanks,
> > > Andrea
> >
> > Andrea,
> >
> > There is no compression of avi files on OSX at this time.
> We've updated
> > the documentation to be more clear on that point.
> Currently AVIFILE
> > only allows compression on Windows. Non-Windows platforms
> can only
> > write uncompressed AVIs.
> >
> > -Dave

Subject: Compression of videos in OSX

From: Andrea Tagliasacchi

Date: 17 Jun, 2008 22:16:02

Message: 5 of 6

Correct.. However I assume that when you use compression you
are doing it because you want to transmit it over network or
save it economically.

Honestly it didn't even come to my mind of playing a move
inside MATLAB. I capture a real time changing figure, and
the I simply wanna save it. It's much better when you have
3D data to discuss about.

Good suggestion about the temp file :)

Ken Prager <prager@ieee.org> wrote in message
<s-KdnSl-W49WOMrVnZ2dnUVZ_s3inZ2d@posted.surewest>...
> But then you can't view the avi from within Matlab, correct?
>
> Also, I wouldn't delete the temporary file unless I'd
confirmed there
> were no errors. That is:
>
> if STATUSVAR ~= 0
> error( STATUSMESSAGE );
> else
> disp('compression completed');
> delete('tempoutput.avi'); % remove temp file
> end
>
>
>
> - Ken P.

Subject: Compression of videos in OSX

From: Ken Prager

Date: 18 Jun, 2008 12:20:58

Message: 6 of 6

A couple of projects ago, we were working on tracking algorithms. The
video was kept in an avi file and the detections were in a text file.
The tracker would grab a frame from the avi file and display it along
with a symbology overlay for the tracks.

I was on a Mac and another colleague was on a PC. He kept trying to
give me compressed avi files to work with which didn't work out so well.

Ken P.


In article <g39d32$9oc$1@fred.mathworks.com>,
 "Andrea Tagliasacchi" <ata2@nospam.cs.sfu.ca> wrote:

> Correct.. However I assume that when you use compression you
> are doing it because you want to transmit it over network or
> save it economically.
>
> Honestly it didn't even come to my mind of playing a move
> inside MATLAB. I capture a real time changing figure, and
> the I simply wanna save it. It's much better when you have
> 3D data to discuss about.
>
> Good suggestion about the temp file :)
>
> Ken Prager <prager@ieee.org> wrote in message
> <s-KdnSl-W49WOMrVnZ2dnUVZ_s3inZ2d@posted.surewest>...
> > But then you can't view the avi from within Matlab, correct?
> >
> > Also, I wouldn't delete the temporary file unless I'd
> confirmed there
> > were no errors. That is:
> >
> > if STATUSVAR ~= 0
> > error( STATUSMESSAGE );
> > else
> > disp('compression completed');
> > delete('tempoutput.avi'); % remove temp file
> > end
> >
> >
> >
> > - Ken P.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
codec Andrea Tagliasacchi 13 Jun, 2008 19:20:06
avi Andrea Tagliasacchi 13 Jun, 2008 19:20:06
osx Andrea Tagliasacchi 13 Jun, 2008 19:20:06
rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com