Writing codecs in C ?

mtarek16 101 Jul 19, 2008 at 22:35


I’m totally new to sound and music programming (I don’t even know whether I’m in the right section or not ! ) so, I’ll try to make my question as clear as possible and I would be really grateful if anyone could help me.

I want to learn about how to write codecs in C to enable a media player to play .rm and .ram for example.

Where should I go to find info about this ? if there are any books on the topic, tutorials .. etc . because I googled a lot and couldn’t find what I was looking for.

excuse me if this sounded totally dumb :). I really have no idea about that specific topic.

6 Replies

Please log in or register to post a reply.

monjardin 102 Jul 20, 2008 at 10:04

Well, a RAM file is easy since it just contains an ASCII URL that redirects you to an RM file. An RealMedia (RM) file is a container format typically used for streaming audio and/or video with the Real Time Streaming Protocol (RTSP).

Now the A/V content is normally encoded and that’s where a codec comes into play. There are probably a dozen different codecs that could be used in a RealMedia container, and most are likely protected intellectual property with hefty licensing fees.

Other than adding VoIP to an application using the speex codec and a quick and dirty implementation of Realtime Transport Protocol (RTP) many years ago, I don’t have much experience in this realm. So, I don’t know of any books/references to refer to you.

PS - I do remember discussing audio compression using convolution filters from my college signals and systems class though! :geek:

Edit: It may be easier to start with something very open with easily obtainable specifications like Ogg/Theora/Vorbis. In this case ogg is a container analogous to RM, theora is a video codec and vorbis is an audio codec. These are all open formats as opposed to proprietary RealNetworks IP.

Skavenger 101 Jul 21, 2008 at 12:59

Or you could just install RealAlternative.

mtarek16 101 Jul 21, 2008 at 17:23

thanks a lot monjardin, still, I believe I need something introductory.

@skavenger :

Thanks for taking the time to reply but I’m not looking for how to play rm files, I actually want to learn how to de-/encode rm and convert it to other formats ( by writing my own converter, for the sake of learning).

Reedbeta 168 Jul 21, 2008 at 18:41

For the sake of learning, you probably want to use a well-documented open format rather than something closed and proprietary like .rm, otherwise you’ll spend most of your time banging your head against the file format rather than learning how to write a codec. The Ogg formats suggested by monjardin are open formats and would be good for this purpose. However for something introductory you may want to try something very simple such as renaming a .wav file to another extension like .mywav, and then creating a codec to let media players read the .mywav files.

As for actually writing a codec, I don’t have any experience there so I unfortunately don’t know where to point you. You could try downloading the source to some open-source codec, looking to see how it interfaces with Windows and then look up the appropriate keywords in the MSDN (hopefully, info about WMP codecs should be in there, someplace).

kariem2k 101 Dec 18, 2008 at 16:43

First of all this proprietary format so you it is illegal to make an application that plays that format without asking for permission you don’t want your application end like StreamRipper.
To be able to make a codec for that format, you must first reverse-engineer the format because you don’t even know what the audio compression techniques employed, how is it stored in the file, etc because i think they have not declared there format.
Reverse engineering the format is the problem not writing the codec itself, it will be very tedious task you must know how the audio compressing works, they are using regular PCM or they uses something like vocoders, etc.
I did not see(Maybe there is, i don’t know if there please tell me about it) any applications that convert that format into another format, unless they use a workaround of playing the rm file and recording the audio output and saving it in the other format.
Finally IMHO Real Alternative just uses realplayer original dlls to decode the audio so it is not really a codec.

_oisyn 101 Dec 20, 2008 at 13:29

First of all this proprietary format so you it is illegal to make an application that plays that format without asking for permission

No it isn’t. It is illegal if you use an algorithm protected by copyright or patent law to encode/decode the information in the file. But you can’t protect a file format per se, so if you devise your own algorithm to play the file which is very different from the protected algorithm, they can’t do much about it.