Problems w/ QTKit on Snow Leopard Server

Discussion in 'Mac Programming' started by CaptainKebab, Apr 12, 2010.

  1. CaptainKebab macrumors newbie

    Joined:
    Apr 12, 2010
    #1
    Hey all, first post so I'll make it a good one ;).

    I have written a script to pull a frame image from a QuickTime Movie. It works great on Snow Leopard and Leopard, but I get different results on Snow Leopard Server. When pulling on the non-server OS I get the frame at the specified time. However when I execute the exact same script with the exact same movie on SL Server I get a completely black frame (not sure if its black because of an error or because its pulling the first frame - which happens to be black). Would you mind taking a look at my code and see if I'm doing anything wrong? Has anybody else experienced weird results with QTKit on SL Server?

    EDIT: Also works on Leopard Server

    The script is written in Ruby so I apologize if its a little hard to read for you Objective-C people. Same commands, just slightly different syntax :). I appreciate the help!

    require "osx/cocoa"
    include OSX
    OSX.require_framework 'QTKit'

    # set the save path
    savePath = "test.png"

    # set the time code
    timeCode = 889

    # initailize the movie
    qtmovie = OSX::QTMovie.alloc.initWithFile_error("movie.mov", nil)

    # determine the timescale of the movie
    timeScale = qtmovie.attributeForKey('QTMovieTimeScaleAttribute')

    # build a QTTime object using the timeCode and the timeScale
    time = OSX::QTMakeTime(timeCode, timeScale)

    # pull the frame
    frame = qtmovie.frameImageAtTime_withAttributes_error(time, {QTMovieFrameImageType => QTMovieFrameImageTypeNSImage}, nil)

    # save the frame
    bitmapRep = OSX::NSBitmapImageRep.alloc.initWithData(frame.TIFFRepresentation)
    blob = bitmapRep.representationUsingType_properties(NSPNGFileType, nil)
    blob.writeToFile_atomically(savePath, false)
     
  2. CaptainKebab thread starter macrumors newbie

    Joined:
    Apr 12, 2010
    #2
    Well for those of you who might have a similar issue, when I explicitly specified the gamma of the representation when saving as PNG, the frame came out fine. Weird that this must be set for SL Server and not Leopard, Snow Leopard, or Leopard Server.
     
  3. CaptainKebab thread starter macrumors newbie

    Joined:
    Apr 12, 2010
    #3
    Ok, well I'm back. It seems that the results are inconsistent. Having the same issues today and am now explicitly setting the gamma and the image interlaced property. Still not sure why I am getting black frames on Snow Leopard server and no other OS.

    If anyone has any ideas I would be super grateful! You might even get an internet brownie for helping lol
     
  4. foidulus macrumors 6502a

    Joined:
    Jan 15, 2007
    #4
    One thing to make sure of

    is that you have to run the getFrameImageAtTime method when you can create a new window, ie the user running it is the current logged in user. Otherwise it gets weird.

    Not sure why Apple made this a requirement, but they did.
     

Share This Page