QTKit glitchy on Snow Leopard Server - Help!

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)
 
L

Louis-Philippe

[Note: parts of this message were removed to make it a legal post.]

I can't identify your problem in the code,
If that may help you find the bug, I had lot of trouble lately with
timescales... behaviour is not consistent with the arrival of
Quicktime-X... I would try to print debug info from my time values while
the program is running, just to be sure they are what I think they are.
 
S

Spencer Rogers

Hmmm good idea. It seems the timeScale comes out at 600 on either
machine, but one frame is still turning out black.

Are there any other attributes I should check to help debug this thing?
I tried printing out the time object that was created from the time code
and time scale, but I can't get the toString method to work from the
QTTime class reference. Any ideas?
 
L

Louis-Philippe

[Note: parts of this message were removed to make it a legal post.]

QTTime and QTTimeRange are C Struct...
you should be able to call .timeValue and .timeScale on QTTime,
and also QTTimeRange should give you a .time and a .duration of QTTime
types...
 
S

Spencer Rogers

Ok, I have a little more info after watching this thing.

This script (expanded) is part of our web application and runs on our
webserver (w/ Snow Leopard Server). Things work ok for a short time but
after a few executions of the code in our Rails app, black frames start
being produced. When this happens, the terminal window running our
server instance gets a title of qtKitServer and then if I execute the
script posted above I can't get any of the frames to turn out normally.
Restarting the web-server instance fixes this issue - the script will
work, but only for a short time, as the cycle repeats itself.

I'm unsure as to what causes this lock up (as it works the first few
times then starts making black frames). In fact, the code has not
changed in over 8 months but all of a sudden this problem arises. The
only change was that we upgraded from Leopard Server to Snow Leopard
Server. Is this a problem with Apple's SL Server? I've tried
installing QT7 Pro (just incase) and updating Ruby, Rails, and
RubyCocoa. Still no change. I'm curious if the 10.6.3 update will fix
this, but we noticed 10.6.3 also breaks the lib-xml ruby plugin (causes
segmentation faults), so we won't be doing that right away.
 
S

Spencer Rogers

Maybe the QTMovie object isn't being release properly after each call so
qtkitServer continues to run? I've noticed that killing that process in
Activity Monitor will allow the frames to work again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top