public
Description: Ruby wrapper for the QuickTime C API.
Homepage:
Clone URL: git://github.com/ryanb/rmov.git
rmov /
name age message
file .autotest Fri Oct 03 10:05:43 -0700 2008 fixing .autotest file to ignore spec/output dir... [ryanb]
file .gitignore Fri Oct 03 14:02:53 -0700 2008 adding movie.export_image as a generic way to e... [ryanb]
file CHANGELOG Tue Sep 15 14:20:23 -0700 2009 releasing 0.1.6 [ryanb]
file LICENSE Thu Oct 02 16:35:05 -0700 2008 releasing initial 0.1.0 with documentation [ryanb]
file Manifest Tue Jul 28 16:11:56 -0700 2009 releasing v0.1.5 [ryanb]
file README.rdoc Tue Sep 15 14:20:23 -0700 2009 releasing 0.1.6 [ryanb]
file Rakefile Tue Sep 15 14:20:23 -0700 2009 releasing 0.1.6 [ryanb]
file TODO Fri Oct 03 08:07:36 -0700 2008 adding track.volume getter and setter [ryanb]
directory ext/ Tue Sep 15 14:00:49 -0700 2009 force compile in 32 bit [ryanb]
directory lib/ Mon Jul 13 11:17:20 -0700 2009 reorganizing how movie operations are performed... [ryanb]
directory spec/ Tue Jul 28 16:00:52 -0700 2009 fixing export process of saving settings to fil... [ryanb]
directory tasks/ Fri Sep 19 13:38:49 -0700 2008 adding setup rake task to compile the c extension [ryanb]
README.rdoc

RMov

Open, edit, and export QuickTime movies all within Ruby! This is an unofficial wrapper around Apple’s QuickTime C API. Mac OS X required.

Install

Install the gem:

  gem install rmov

And then load it in your project:

  require 'rmov'

32 vs 64 Bit

Snow Leopard introduces a push towards 64 bit, and by default Ruby will run in 64 bit. Unfortunately the QuickTime C API will not be moving to 64 bit (see arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars/6 ). Therefore RMov 0.1.6 and later will always be installed under 32 bit.

This means You will not be able to use this gem while running the default 64 bit Ruby. Instead you will need to run Ruby in 32 bit mode. You can do so with this command.

  arch -i386 ruby path/to/script.rb

Usage

There are many methods for editing, compositing, and exporting movies. Here are some examples.

Editing

  movie1 = QuickTime::Movie.open("path/to/movie.mov")
  movie2 = QuickTime::Movie.open("path/to/another_movie.mov")

  # add movie2 to the end of movie1
  movie1.append_movie(movie2)

  # make a new movie out of a section of movie 1
  # this will delete 5 seconds out of the movie at 2 seconds in
  movie3 = movie1.clip_section(2, 5)

  # You can insert that part back into the movie at 8 seconds in
  movie1.insert_movie(movie3, 8)

Compositing

  movie = QuickTime::Movie.open("path/to/movie.mov")
  watermark_movie = QuickTime::Movie.open("path/to/watermark.png")

  # add watermark track onto the entire length of the movie
  movie.composite_movie(watermark_movie, 0, movie.duration)

  # grab the watermark track
  watermark = movie.video_tracks.last

  # enable the alpha transparency of the png
  watermark.enable_alpha

  # make the watermark half the size
  watermark.scale(0.5, 0.5)

  # offset into lower left corner
  watermark.translate(10, movie.height - watermark.height - 10)

Exporting

Usually exporting is done through a user interface the first time. The settings can then be saved to a file. After that you can load these settings without interfering the user with the dialog again.

  exporter = movie.exporter

  # if we already have saved the settings, load those
  if File.exist? "settings.st"
    exporter.load_settings("settings.st")
  else
    # otherwise open the QuickTime GUI settings dialog
    exporter.open_settings_dialog

    # save settings to a file so we don't have to bother user next time
    exporter.save_settings("settings.st")
  end

  # export the movie to a file and report the progress along the way
  exporter.export("movie.mov") do |progress|
    percent = (progress*100).round
    puts "#{percent}% complete"
  end

Documentation

See QuickTime::Movie and QuickTime::Track in the RDoc for more information.

rmov.rubyforge.org

Development

This project can be found on github at the following URL.

github.com/ryanb/rmov

If you find a bug, please send me a message on GitHub.

If you would like to contribute to this project, please fork the repository and send me a pull request.