S
Spencer Rogers
I have written a script to pull a frame image from a QuickTime Movie. It
works great on Snow Leopard, Leopard, and Leopard Server but I get weird
results on Snow Leopard Server.
When pulling on the 3 working OSs 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?
require "osx/cocoa"
include OSX
OSX.require_framework 'QTKit'
# set the save path
savePath = "test.png"
# set the time code
timeCode = 1000
# 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
properties = {NSImageGamma => 1.0, NSImageInterlaced => false}
bitmapRep =
OSX::NSBitmapImageRep.alloc.initWithData(frame.TIFFRepresentation)
blob = bitmapRep.representationUsingType_properties(NSPNGFileType,
properties)
blob.writeToFile_atomically(savePath, false)
works great on Snow Leopard, Leopard, and Leopard Server but I get weird
results on Snow Leopard Server.
When pulling on the 3 working OSs 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?
require "osx/cocoa"
include OSX
OSX.require_framework 'QTKit'
# set the save path
savePath = "test.png"
# set the time code
timeCode = 1000
# 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
properties = {NSImageGamma => 1.0, NSImageInterlaced => false}
bitmapRep =
OSX::NSBitmapImageRep.alloc.initWithData(frame.TIFFRepresentation)
blob = bitmapRep.representationUsingType_properties(NSPNGFileType,
properties)
blob.writeToFile_atomically(savePath, false)