How to add a new codec to Perian?

57 views
Skip to first unread message

ischou

unread,
Dec 21, 2011, 5:29:21 PM12/21/11
to perian discussion
I would like to be able to open some uncompressed AVI's on mac via
Perian. FFMpeg is able to open then, but I'm not sure where to begin.

I'm not trying to pose this as a "feature request" but rather how can
I go about adding this ability and compiling the Perian component
myself.

This revision: http://trac.perian.org/ticket/419 seems to indicate
that it is now fairly straightforward to add a new codec, but
"uncompressed" or "rawvideo" (as is reported by ffmpeg) is not really
a codec.

I would greatly appreciate any pointers anyone can provide me to get
me started.

Thanks.

Graham Booker

unread,
Dec 21, 2011, 5:43:06 PM12/21/11
to perian-...@googlegroups.com
On Wed, Dec 21, 2011 at 4:29 PM, ischou <ic...@trinity.westhost.com> wrote:
I would like to be able to open some uncompressed AVI's on mac via
Perian.  FFMpeg is able to open then, but I'm not sure where to begin.

That likely means that it can be played in Perian; depending on what color space the codec outputs.
 
I'm not trying to pose this as a "feature request" but rather how can
I go about adding this ability and compiling the Perian component
myself.

This revision: http://trac.perian.org/ticket/419 seems to indicate
that it is now fairly straightforward to add a new codec, but
"uncompressed" or "rawvideo" (as is reported by ffmpeg) is not really
a codec.

I'd start with http://trac.perian.org/changeset/1315  That should give you a good start.  FFmpeg (and us by extension) view these as codecs, so the terminology is still correct.  The CODEC definition is a resourceID (I believe you make one here that's not in use), FFmpeg codec id, human readable name, human readable description, fourcc code.  The m4 file is then used to generate .r, .h, and .c files.
 
I would greatly appreciate any pointers anyone can provide me to get
me started.

If you get it working, let us know; we'd appreciate a patch.
 
Thanks.

Chris Forsythe

unread,
Dec 22, 2011, 3:24:05 AM12/22/11
to perian-...@googlegroups.com
We're on #perian on freenode most days if you do any irc'ing. 
 
Thanks.

--
You received this message because you are subscribed to the Google Groups "perian discussion" group.
To post to this group, send email to perian-...@googlegroups.com.
To unsubscribe from this group, send email to perian-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/perian-discuss?hl=en.

ischou

unread,
Dec 22, 2011, 2:18:02 PM12/22/11
to perian discussion
Thank you very much!

That link was a huge shove in the right direction. It only took a
moment to find that the REGISTER_DECODER() functions have been moved
out of ff_MovieImporter.c to FFMpegUtils.c.

I think I have a good idea of how to add codecs, but now I'm at the
point where I'd like to try to test my component.

I tried just drag-n-dropping my compiled Perian.component into my /
Library/QuickTime directory, but it appears to do nothing.

Must I reboot in order for my changed Perian component to get used by
the system or the QuickTime player app? Or is there a "safer" way to
test my builds without having to muck with the Perian that was
installed?

On Dec 21, 2:43 pm, Graham Booker <gboo...@cod3r.com> wrote:
> On Wed, Dec 21, 2011 at 4:29 PM, ischou <ic...@trinity.westhost.com> wrote:
> > I would like to be able to open some uncompressed AVI's on mac via
> > Perian.  FFMpeg is able to open then, but I'm not sure where to begin.
>
> That likely means that it can be played in Perian; depending on what color
> space the codec outputs.
>
> > I'm not trying to pose this as a "feature request" but rather how can
> > I go about adding this ability and compiling the Perian component
> > myself.
>
> > This revision:http://trac.perian.org/ticket/419seems to indicate
> > that it is now fairly straightforward to add a new codec, but
> > "uncompressed" or "rawvideo" (as is reported by ffmpeg) is not really
> > a codec.
>
> I'd start withhttp://trac.perian.org/changeset/1315 That should give you

Graham Booker

unread,
Dec 22, 2011, 2:19:43 PM12/22/11
to perian-...@googlegroups.com
On Thu, Dec 22, 2011 at 1:18 PM, ischou <ic...@trinity.westhost.com> wrote:
Thank you very much!

That link was a huge shove in the right direction.  It only took a
moment to find that the REGISTER_DECODER() functions have been moved
out of ff_MovieImporter.c to FFMpegUtils.c.

I think I have a good idea of how to add codecs, but now I'm at the
point where I'd like to try to test my component.

I tried just drag-n-dropping my compiled Perian.component into my /
Library/QuickTime directory, but it appears to do nothing.

Must I reboot in order for my changed Perian component to get used by
the system or the QuickTime player app?  Or is there a "safer" way to
test my builds without having to muck with the Perian that was
installed?

You have to restart any applications that you want to use for test.  Lion made this more difficult with their hiding of processes.  Use activity monitor or ps and kill the QT player process.  Then it'll use the new component.
 

On Dec 21, 2:43 pm, Graham Booker <gboo...@cod3r.com> wrote:
> On Wed, Dec 21, 2011 at 4:29 PM, ischou <ic...@trinity.westhost.com> wrote:
> > I would like to be able to open some uncompressed AVI's on mac via
> > Perian.  FFMpeg is able to open then, but I'm not sure where to begin.
>
> That likely means that it can be played in Perian; depending on what color
> space the codec outputs.
>
> > I'm not trying to pose this as a "feature request" but rather how can
> > I go about adding this ability and compiling the Perian component
> > myself.
>
> > This revision:http://trac.perian.org/ticket/419seems to indicate
> > that it is now fairly straightforward to add a new codec, but
> > "uncompressed" or "rawvideo" (as is reported by ffmpeg) is not really
> > a codec.
>
> I'd start withhttp://trac.perian.org/changeset/1315 That should give you
> a good start.  FFmpeg (and us by extension) view these as codecs, so the
> terminology is still correct.  The CODEC definition is a resourceID (I
> believe you make one here that's not in use), FFmpeg codec id, human
> readable name, human readable description, fourcc code.  The m4 file is
> then used to generate .r, .h, and .c files.
>
> > I would greatly appreciate any pointers anyone can provide me to get
> > me started.
>
> If you get it working, let us know; we'd appreciate a patch.
>
>
>
>
>
>
>
> > Thanks.

ischou

unread,
Dec 23, 2011, 8:52:33 PM12/23/11
to perian discussion
I found my problem. I had Perian.component in both /Library/Quicktime
as well as ~/Library/Quicktime and the system kept ignoring the one
that I put in /Library/Quicktime.

I've added

Codec(kRawVideoCodecInfoResID, CODEC_ID_RAWVIDEO, "Raw Video",
"Decompresses video stored in raw uncompressed format.", 0x00000000 )

to codecList.m4 and

REGISTER_DECODER(rawvideo);

to FFMpegUtils.c and things compile, but it seems that neither the
getCodecID() never gets called. What registers a particular codec to
be opened with Perian with QuickTime? Or is the 0x00000000 fourcc a
problem?

I put some fprintf() into my code to prove that the one that I've
compiled is getting called. I get those debug messages on the Console
when I open AVI's with codecs that only Perian can handle, but I don't
get any of my debugging messages when I try to open my uncompressed
raw AVIs.

More hints please? Thank you.
> > > > This revision:http://trac.perian.org/ticket/419seemsto indicate
> > > > that it is now fairly straightforward to add a new codec, but
> > > > "uncompressed" or "rawvideo" (as is reported by ffmpeg) is not really
> > > > a codec.
>
> > > I'd start withhttp://trac.perian.org/changeset/1315That should give you

Graham Booker

unread,
Dec 23, 2011, 10:18:46 PM12/23/11
to perian-...@googlegroups.com

On Dec 23, 2011, at 7:52 PM, ischou wrote:

> I found my problem. I had Perian.component in both /Library/Quicktime
> as well as ~/Library/Quicktime and the system kept ignoring the one
> that I put in /Library/Quicktime.
>
> I've added
>
> Codec(kRawVideoCodecInfoResID, CODEC_ID_RAWVIDEO, "Raw Video",
> "Decompresses video stored in raw uncompressed format.", 0x00000000 )
>
> to codecList.m4 and
>
> REGISTER_DECODER(rawvideo);
>
> to FFMpegUtils.c and things compile, but it seems that neither the
> getCodecID() never gets called. What registers a particular codec to
> be opened with Perian with QuickTime? Or is the 0x00000000 fourcc a
> problem?

Yes, that would likely be a problem; See below:

> I put some fprintf() into my code to prove that the one that I've
> compiled is getting called. I get those debug messages on the Console
> when I open AVI's with codecs that only Perian can handle, but I don't
> get any of my debugging messages when I try to open my uncompressed
> raw AVIs.

You can actually use the debugger. It's tricky, and Apple strives to make it more and more difficult. You can add QuickTime Player as an application to Xcode, and then debug it. You have to get info on the file and run it in 32-bit mode since it won't work in 64-bit mode (QuickTime's architecture is 32-bit). This will *NOT* work in QT Player 7 since Apple changed how dtrace works with it and my bug report on the subject was marked works as intended.

The codec entry adds, among other things, an entry to the resource files. Check the .r files to make sure it's in there. In there, it registers the Perian component as a codec for a particular fourcc or set of fourccs. I imagine that Apple's code will reject a fourcc of 0x00000000. The avi file likely assigns a fourcc to this codec already, so you should likely use that in the codec entry. I'd suggest using QT Player 7 as the info box tends to give you the fourcc. Otherwise, you can save a reference movie with it and open that with dumpster or something to see the fourcc there, but I think that putting printfs in the code is likely easier than this route. I'm betting the fourcc is ms followed by a 16-bit number since many of AVIs use these.


- Graham


Reply all
Reply to author
Forward
0 new messages