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 9

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 9

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 9

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 9

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 9

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 9

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.

Subject: Compression of videos in OSX

From: John Ferguson

Date: 21 Apr, 2010 15:43:04

Message: 7 of 9

Hi,

I'm having a little trouble getting your compression method to work. If, for example, I say:
%%%%%%%%
x=0:6;
y=sin(x);
figure(1)
clf

aviobj = avifile('tempoutput.avi','fps', 1);
for i=1:numel(x)
    plot(x(1:i),y(1:i))
    aviobj = addframe(aviobj,getframe(figure(1)));
end
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
%%%%%%%%

I get the error message: /bin/bash: mencoder: command not found

Clearly, the mencoder is not being found, but I am successfully able to use it with ffmpegX. Is there something specific I need to do to get matlab to call it? Sorry for the amateur question, but this would save me lots of time with my data.

Thanks,

John

"Andrea Tagliasacchi" <ata2@nospam.cs.sfu.ca> wrote in message <g2uv96$5bu$1@fred.mathworks.com>...
> 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: John Ferguson

Date: 21 Apr, 2010 15:44:05

Message: 8 of 9

Hi,

I'm having a little trouble getting your compression method to work. If, for example, I say:
%%%%%%%%
x=0:6;
y=sin(x);
figure(1)
clf

aviobj = avifile('tempoutput.avi','fps', 1);
for i=1:numel(x)
    plot(x(1:i),y(1:i))
    aviobj = addframe(aviobj,getframe(figure(1)));
end
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
%%%%%%%%

I get the error message: /bin/bash: mencoder: command not found

Clearly, the mencoder is not being found, but I am successfully able to use it with ffmpegX. Is there something specific I need to do to get matlab to call it? Sorry for the amateur question, but this would save me lots of time with my data.

Thanks,

John

"Andrea Tagliasacchi" <ata2@nospam.cs.sfu.ca> wrote in message <g2uv96$5bu$1@fred.mathworks.com>...
> 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: Andrea Tagliasacchi

Date: 21 Apr, 2010 15:53:03

Message: 9 of 9

Mancoder needs to be found by the program.
You would need to add it to the system path.

Open your /Users/you/.bashrc and edit the path adding the mancoder
bin folder, so that anywhere in your system you will able to execute it.

--
Andrea

"John Ferguson" <jfwrx@yahoo.com> wrote in message <hqn6g5$gu2$1@fred.mathworks.com>...
> Hi,
>
> I'm having a little trouble getting your compression method to work. If, for example, I say:
> %%%%%%%%
> x=0:6;
> y=sin(x);
> figure(1)
> clf
>
> aviobj = avifile('tempoutput.avi','fps', 1);
> for i=1:numel(x)
> plot(x(1:i),y(1:i))
> aviobj = addframe(aviobj,getframe(figure(1)));
> end
> 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
> %%%%%%%%
>
> I get the error message: /bin/bash: mencoder: command not found
>
> Clearly, the mencoder is not being found, but I am successfully able to use it with ffmpegX. Is there something specific I need to do to get matlab to call it? Sorry for the amateur question, but this would save me lots of time with my data.
>
> Thanks,
>
> John
>
> "Andrea Tagliasacchi" <ata2@nospam.cs.sfu.ca> wrote in message <g2uv96$5bu$1@fred.mathworks.com>...
> > 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

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

Contact us at files@mathworks.com