I´ve been wondering if it is possible to find out which Codec is used to Decompress a Quicktime Movie (like h.264, motion jpeg.. ), preferable as NSString
. I searched through the Quicktime
and QTKit
api and all gettable attributes with no success, but I am sure开发者_C百科 there must be a way to do this, but how?
I think you're having this difficulty because you're misunderstanding the nature of a Quicktime movie - it doesn't make sense to ask what the codec of a movie is, and that's why you're not finding it in the documentation for movies.
Quicktime movies are made of a collection of tracks (eg. video track, audio track etc.) and each track references one or more media (the actual data). It's the media that is compressed with a particular codec. Usually a movie will have a video track and an audio track, for instance, each of which will be compressed with a different codec (h.264 and aac maybe) - so there isn't one codec for the whole movie.
To find the codec used to compress the video track of the movie (which sounds like what you're trying to do) you need to first get a reference to that track from the movie, then get a reference to the media of that track, then find out the codec used for that media. To get information about how the samples for a particular media object are stored you need to use the getmediasampledescription call.
If you're using QTKit, get the C-level media reference by calling [media quicktimeMedia] - then you can pass this to getmediasampledescription to get the info you're looking for - the codec 4-digit identifer is in the cType field of the returned sample description.
There's a bit of sample code in this apple support list posting :
http://lists.apple.com/archives/cocoa-dev/2005//Aug/msg00556.html
精彩评论