Find out the Codec for a Quicktime Movie

有些话、适合烂在心里 提交于 2019-12-08 10:45:28

问题


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 there must be a way to do this, but how?


回答1:


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



来源:https://stackoverflow.com/questions/5842920/find-out-the-codec-for-a-quicktime-movie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!