# QTKit glitchy on Snow Leopard Server - Help!

**URL:** <https://www.ruby-forum.com/t/qtkit-glitchy-on-snow-leopard-server-help/186883>\
**Category:** Ruby\
**Created:** [April 13, 2010, 7:27pm UTC](https://www.ruby-forum.com/t/qtkit-glitchy-on-snow-leopard-server-help/186883 "2010-04-13T19:27:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![spencer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8dc957/32.png) [@spencer](https://www.ruby-forum.com/u/spencer)\
**Post date:** [April 13, 2010, 7:27pm UTC](https://www.ruby-forum.com/t/qtkit-glitchy-on-snow-leopard-server-help/186883/1 "2010-04-13T19:27:40Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![spencer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8dc957/32.png) [@spencer](https://www.ruby-forum.com/u/spencer)\
**Post date:** [April 14, 2010, 3:36pm UTC](https://www.ruby-forum.com/t/qtkit-glitchy-on-snow-leopard-server-help/186883/2 "2010-04-14T15:36:14Z")

</div>

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.

2010/4/13 Spencer R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![spencer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8dc957/32.png) [@spencer](https://www.ruby-forum.com/u/spencer)\
**Post date:** [April 14, 2010, 5:26pm UTC](https://www.ruby-forum.com/t/qtkit-glitchy-on-snow-leopard-server-help/186883/3 "2010-04-14T17:26:03Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![spencer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8dc957/32.png) [@spencer](https://www.ruby-forum.com/u/spencer)\
**Post date:** [April 14, 2010, 5:49pm UTC](https://www.ruby-forum.com/t/qtkit-glitchy-on-snow-leopard-server-help/186883/4 "2010-04-14T17:49:10Z")

</div>

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…

2010/4/14 Spencer R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![spencer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8dc957/32.png) [@spencer](https://www.ruby-forum.com/u/spencer)\
**Post date:** [April 15, 2010, 7:58pm UTC](https://www.ruby-forum.com/t/qtkit-glitchy-on-snow-leopard-server-help/186883/5 "2010-04-15T19:58:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![spencer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8dc957/32.png) [@spencer](https://www.ruby-forum.com/u/spencer)\
**Post date:** [April 15, 2010, 5:33pm UTC](https://www.ruby-forum.com/t/qtkit-glitchy-on-snow-leopard-server-help/186883/6 "2010-04-15T17:33:36Z")

</div>

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.
