VideoHelp Forum




+ Reply to Thread
Results 1 to 13 of 13
  1. Hmm I'm pretty sure that they do not depend on just checking the file extension because I can rename mp3 files and they can still play it, hence the right codec was used. So for sure it opens the file, but how do they know what codec to use? Do they try every codec they have until they can play it? I tried searching for the designs of various players, but I was not able to find any explanation on how they implement it..

    Thanks in advance!
    Quote Quote  
  2. Mod Neophyte redwudz's Avatar
    Join Date
    Sep 2002
    Location
    USA
    Search Comp PM
    Yes, they check the file extension. If you rename a file with say, .avi you are just changing the name, not the file extension. You have to be able to see the hidden name of the filetype in windows. 'Folder options' can show the registered filetypes and you can also make the hidden file types visable.
    Quote Quote  
  3. I'm sorry but I didn't fully get what you mean. I don't think I was clear enough on my first post.... Here's what I did.

    I have a file Jumper.mp3, I renamed it to Jumper.avi using command prompt. When I view the new file(Jumper.avi) in windows explorer, it is now recognized as a video clip file (avi) and is now opened with media player. Hmm so when I open it using media player, it should call the avi codec if it only checks the file extension or the registry.... But it was still able to play the mp3 file so I guess the mp3 codec was called after all.
    Quote Quote  
  4. Certainly for .avi files, there is a 4 character code (4CC) in the file header info that specifys which decompressor is needed. There is one for each of audio and video. I would assume audio files use something similiar, some info in the file header.
    Quote Quote  
  5. yep! As far as I know, Mp3's have header information within the file.... So I guess the media players do try to open the file with every codec until it comes up with a match?
    Quote Quote  
  6. Originally Posted by pablowablo
    yep! As far as I know, Mp3's have header information within the file.... So I guess the media players do try to open the file with every codec until it comes up with a match?
    paths to codecs and their identifiers are stored in the registry. So my guess is the media player reads the file header, gets the info on what codec is required and the searches the registry to find the codecs filename and location so that it can be loaded.
    Quote Quote  
  7. Member
    Join Date
    Jun 2003
    Location
    Montreal, Canada
    Search Comp PM
    There is a no such thing as an AVI codec per se. The AVI format is just a container for various formats, and one format it supports is mp3 (as in a divx movie that contains video compressed with the divx codec and the audio compressed with the mp3 codec). My guess is that windows openned the AVI file, found an audio codec to use and played it, not bothering with the fact there was no video content.

    Try renaming your jumper.mp3 file to jumper.wma or jumper.wav or you can even make up your own jumper.abc and see what happens. I don't think it will work, even though if your PC is a windows machine, it surely can decode .wma (windows media audio) and wav extensions. As for how a player knows whicvh codec to use, there might be some part related to the file extensions (for example .rm would be real media) and there is indeed a code inside the files (AVI do as bugster already mentioned) that call the right codec). You can actually experience it using the various tools in this site that let you identify the codec used in an AVI file. I think the quicktime format is also a wrapper to some extent because you can choose many different codecs when you convert a file to quicktime format.
    Quote Quote  
  8. When you double click on a file to open it Windows looks at the file extension to determine which program to launch to open the file. This information is maintained in the Registry.

    AVI files have a standardized header that indicates what streams are in the file (video, audio). Also in the file are "four CC" codes indicating the codecs used by the streams. The Registry contains information about what decoders support what codecs. For example the Xvid codec can decode both Divx and Xvid video.

    If the file doesn't have the expected AVI header, some players will examine the first part of the file for clues to what the file type is. Each type of file has it's own characteristic header layout. WMP, for example, can often figure out if the file an MP3, WAV, or AVI even if it's misnamed.
    Quote Quote  
  9. paths to codecs and their identifiers are stored in the registry.
    Hmmm by this do you mean that there is somewhat of a database in the registry containing the codec ID?

    So my guess is the media player reads the file header, gets the info on what codec is required and the searches the registry to find the codecs filename and location so that it can be loaded.
    I see, that may be it... I have another question though, to find the file header it must first know how to find it right? let's say for mp3 files, it looks for the sync bits (12 bits of 1's) and then checks the following information in the header. So does the player try every possible 4CC's or sync? I still don't get it. sorry


    Try renaming your jumper.mp3 file to jumper.wma or jumper.wav or you can even make up your own jumper.abc and see what happens. .
    I renamed it to Jumper.anm and it was still able to play it.. So I'm pretty sure it called the mp3 codec.

    If the file doesn't have the expected AVI header, some players will examine the first part of the file for clues to what the file type is. Each type of file has it's own characteristic header layout. WMP, for example, can often figure out if the file an MP3, WAV, or AVI even if it's misnamed.
    So the player first looks for the header and then if there is a match in the registry, it calls the particular codec? Is this what you mean?

    I have another question though, how does the player find the header of the file? I think what I want to ask in the first place is how the standard way of checking what file type a file is (if there's any)... Is it sufficient that the player finds these 4CC codes? Because isn't it possible that these codes exist in some other file types? (since it is just a combination of ones and zeros)

    I'm sorry if my questions seem absurd to you guys, but I have to develop a multimedia streaming player and a requirement is that it should support plugins. for codecs.. So I cannot hardcode the part where it checks what codecs to use because in the future there might be other codecs to be added... I'm thinking that the codecs(plugins) are called by the player itself to check if it can decode the file since the player has no way of knowing what future codecs can decode...
    Quote Quote  
  10. Well, it's called the "header" because it's at the head (start) of the file. Different multimedia files have different header lengths and layouts.

    Since you are writing your own player you can choose from several approaches:

    At the highest level you can use Windows Media Player to play files within your application's window. This doesn't require any knowledge of headers, codecs, or file layouts. You just say here's a filename, here's a window -- play it.

    At the other end of the spectrum, you could parse everything yourself, write your own decoders, etc. That's obviously a very large job.

    In between those two extremes are Microsoft's VFW or WMD APIs. With these you don't need to worry about codecs (for playback) because Windows takes care of the details. The MSDN disks have a sample AVI player using VFW.

    For correctly named files VFW or WMD should work. For incorrectly named file you'll probably have to examine the first part of the file manually (ie using regular binary file open, read, close functions) and try to figure out what type of file it is. Then use the appropriate library functions to play the file.

    The API libraries probably don't simply try to play file a file with each codec until it finds one that works. This would in all likelyhood cause the program, if not the system, to crash. The registry contains the information about which codec to use for each registered FourCC code. When you install a codec it updates the registry for the types it can play.

    Note that not all file types include FourCC codes. If you need to go to that level you're going to have to read up on file formats.
    Quote Quote  
  11. hello junkmalle, thanks again for the reply!

    Actually, it is my final year project so I would have to do everything myself And to make things harder, the target platform is palm (

    Anyway, I'm pretty sure for Mp3 files the header is not always at the start of the file. What mp3 decoders do to check if it is an mp3 file is to search for the sync word and then interpret the following bytes after that. Unfortunately, my knowledge is limited to mp3 decoding. I do not know how other files are decoded and how the player can possibly know what to check in the file. *sigh*

    The API libraries probably don't simply try to play file a file with each codec until it finds one that works. This would in all likelyhood cause the program, if not the system, to crash.
    That is my concern, I think that calling each codec is the brute force solution for this...

    The registry contains the information about which codec to use for each registered FourCC code. When you install a codec it updates the registry for the types it can play.
    I see, this might be the answer I was looking for. I will do some research on this. Hmm is the FourCC code for avi's always at the start? There are different FourCC codes for the audio and video streams right? Maybe there is no standard way of finding out type a file is after all.. Since not all formats provide FourCC codes, the player must have other ways of checking for these files.
    *sigh* sorry if I'm too darn incoherent.[/quote]
    Quote Quote  
  12. There is always info about extension of the file in the file header (any file).
    Then comes certain format header , f.ex. AVI,mp3 etc according to info.
    If you modified that file header you'd have to worry but just renaming the file
    is safe for recognizing by good apps.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!