Prev: How to find multiple matches in a string
Next: Gem help
From: Spencer Rogers on 13 Apr 2010 13:27 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) -- Posted via http://www.ruby-forum.com/.
From: Louis-Philippe on 14 Apr 2010 09:35 [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. 2010/4/13 Spencer Rogers <spencerevanrogers(a)gmail.com> > 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) > -- > Posted via http://www.ruby-forum.com/. > >
From: Spencer Rogers on 14 Apr 2010 11:26 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? -- Posted via http://www.ruby-forum.com/.
From: Louis-Philippe on 14 Apr 2010 11:48 [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... 2010/4/14 Spencer Rogers <spencerevanrogers(a)gmail.com> > 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? > > -- > Posted via http://www.ruby-forum.com/. > >
From: Spencer Rogers on 15 Apr 2010 11:34
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. -- Posted via http://www.ruby-forum.com/. |