From: Daniel Greig Date: 2006-10-12T08:21:22+09:00 Subject: Re: Quicktime com automation - how do I call it? For anyone interested - the quicktime api is a mysterious and magical thing... Below is a snippet that will open quicktime, select the middle frame of a movie, set it as the poster frame and then export it as an image. Yes, there are probably much easier ways to do this (there's a copyFrame function for example), but this works. The only problem I have is that it opens the quicktime player and makes it visible (player.visible= false does nothing). It also seems that it should be possible to achieve the same thing using the "QTOControl.QTControl" object, but setting the movie URL using that object doesn't work - anyone know why (I'm fairly sure I've seen it crash ruby as well)? ======== This doesn't work ======= require 'win32ole' qt = WIN32OLE.new("QTOControl.QTControl") qt = WIN32OLE.new("QTOControl.QTControl") qt.URL = "C:\\temp\\fire.mov" puts qt.Movie ========= This does work ======== require 'win32ole' qtlib = WIN32OLE.new("QuickTimePlayerLib.QuickTimePlayerApp") #get a player and open a movie player = qtlib.Players(1) player.visible = false #this line doesn't work... player.OpenURL('C:\temp\source.mov') #get the controller control = player.QTControl #get the movie and stop it - I don't even want to see it let alone play it.... movie = control.Movie movie.stop #get the quicktime component and add an exporter qt = control.Quicktime qt.Exporters.Add() exporter = qt.Exporters(1) exporter.TypeName = "bmp"; #set the poster frame and go there (although you could really just go there) mid_frame = movie.Duration/2 movie.PosterTime = mid_frame movie.ShowPoster #do the export... exporter.SetDataSource(movie) exporter.DestinationFileName = "C:\\temp\\whatever.bmp" exporter.BeginExport #bye bye player player.close puts "consider it exported..." -- Posted via http://www.ruby-forum.com/.