]> git.sesse.net Git - mlt/blob - src/swig/ruby/thumbs.rb
A little debugging.
[mlt] / src / swig / ruby / thumbs.rb
1 #!/usr/bin/env ruby
2
3 # Required modules
4 require 'mlt'
5
6 # Create the mlt system
7 Mlt::Factory::init
8
9 # Establish the mlt profile
10 profile = Mlt::Profile.new( "quarter_pal" )
11
12 # Get and check the argument
13 file = ARGV.shift
14 name = ARGV.shift
15 size = ARGV.shift
16 size = "176x144" if size.nil?
17 raise "Usage: thumbs.rb file name [ size ]" if file.nil? || name.nil?
18
19 # Create the producer
20 producer = Mlt::Producer.new( profile, file )
21 raise "Unable to load #{file}" if !producer.is_valid
22
23 # Construct the playlist
24 playlist = Mlt::Playlist.new( )
25
26 # Get the out point
27 out = producer.get_int( "out" );
28
29 # Calculate position of frames
30 [ 0, 0.25, 0.5, 0.75, 1 ].each { |x| playlist.append( producer, Integer(x*out), Integer(x*out) ) }
31
32 # Create the thumb nail generator
33 generator = Mlt::Consumer.new( profile, "avformat", "#{name}%d.jpg" )
34 generator.set( "real_time", "0" )
35 generator.set( "progressive", "1" )
36 generator.set( "s", size )
37
38 # Connect the consumer
39 generator.connect( playlist );
40 generator.run