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!
+ Reply to Thread
Results 1 to 13 of 13
-
-
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.
-
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. -
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.
-
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?
-
Originally Posted by pablowablo
-
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. -
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. -
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.
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. .
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.
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... -
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. -
hello junkmalle, thanks again for the reply!
Actually, it is my final year project so I would have to do everything myselfAnd 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.
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.
*sigh* sorry if I'm too darn incoherent.[/quote] -
AVI files are all RIFF format. The format is well documented:
http://msdn.microsoft.com/library/en-us/directx9_c/directx/htm/avirifffilereference.asp -
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.
Similar Threads
-
Advice on Media Players
By glenpinn in forum Newbie / General discussionsReplies: 23Last Post: 30th Apr 2012, 18:48 -
HD Media PLayers
By azfarhus in forum Media Center PC / MediaCentersReplies: 4Last Post: 31st Mar 2012, 04:41 -
Cedocida - "Jittery" playback on some media players/DVD players
By BertRito in forum Newbie / General discussionsReplies: 11Last Post: 4th Aug 2010, 19:20 -
No Sound Coming From Media Player or Online Media Players
By Teac23 in forum AudioReplies: 4Last Post: 11th Jul 2010, 06:52 -
codec and dvd players
By ford10000 in forum Newbie / General discussionsReplies: 4Last Post: 19th Jun 2007, 13:58