Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting a codecs OSType from a UTType format in pyobjc
    primarykey
    data
    text
    <p>I'm currently writing a script that processes batches of quicktimes, and its my first time using pyobjc (I have only written one other really simple script in actual objective-c). I need to be able to determine the four character OSType of the codec of the quicktimes so that I can properly use the same codec for images using addImage_forDuration_withAttributes_()</p> <p>Because pyobjc only has access to the obj-c frameworks, I can't access any of the C functions from it. I am able to get the string format UTType of the codec:</p> <pre><code>from objc import YES, NO, nil from Cocoa import * from QTKit import * movieAttribs = { QTMovieOpenAsyncOKAttribute: NSNumber.numberWithBool_(NO), QTMovieEditableAttribute: NSNumber.numberWithBool_(YES), QTMovieFileNameAttribute: "quicktime.mov" } clip, err = QTMovie.movieWithAttributes_error_(movieAttribs, None) track = clip.tracks()[0] print track.format() # u'Avid DNxHD Codec' </code></pre> <p>At this point I need to get the OSType, which for this codec would be 'AVdn' I'm assuming I want something like this: <a href="https://developer.apple.com/library/mac/#documentation/MobileCoreServices/Reference/UTTypeRef/Reference/reference.html" rel="nofollow noreferrer">https://developer.apple.com/library/mac/#documentation/MobileCoreServices/Reference/UTTypeRef/Reference/reference.html</a> But I don't have access to it in pyobjc</p> <p>My last resort is to shell out to <a href="http://omino.com/sw/qt_tools/man/qt_thing.html" rel="nofollow noreferrer">qt_thing</a> with something like this:</p> <pre><code>qt_thing --type=imco | grep "AVID DNxHD Codec" | awk -F: '{print $2}' # Result: AVdn </code></pre> <p>But this is slower and I would rather do it all in code. I must be missing something that is available to me in the Cocoa/QTKit side of things. Anyone with any experience?</p> <p>There is another SO question that again references using the C api to resolve the codec: <a href="https://stackoverflow.com/questions/5842920/find-out-the-codec-for-a-quicktime-movie">Find out the Codec for a Quicktime Movie</a>, but I can't obviously do that directly form pyobjc as far as I know.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload