Class: RTranscoder::MPEG4IP::MP4Creator

Inherits:
RProgram::Program
  • Object
show all
Defined in:
lib/rtranscoder/mpeg4ip/mp4creator.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ MP4Creator

Creates a new MP4Creator object with the specified path of the mp4creator program.



16
17
18
# File 'lib/rtranscoder/mpeg4ip/mp4creator.rb', line 16

def initialize(path)
  super(path)
end

Class Method Details

.create(options = {}, &block) ⇒ Object

See MP4Creator#create.



23
24
25
# File 'lib/rtranscoder/mpeg4ip/mp4creator.rb', line 23

def self.create(options={},&block)
  self.find.create(options,&block)
end

.mux(options = {}) ⇒ Object

See MP4Creator#mux.



30
31
32
# File 'lib/rtranscoder/mpeg4ip/mp4creator.rb', line 30

def self.mux(options={})
  self.find.mux(options)
end

Instance Method Details

#create(options = {}, &block) ⇒ Object

Runs the mp4creator program with the given options and the given block using MP4CreatorTask.



38
39
40
# File 'lib/rtranscoder/mpeg4ip/mp4creator.rb', line 38

def create(options={},&block)
  run_task(MP4CreatorTask.new(options,&block))
end

#mux(options = {}) ⇒ Object

Muxes audio and video streams together with the specified options.

options must contain the following keys:

:audio

The audio file to add.

:video

The video file to add.

:frame_rate

The frame rate of the video stream.

:output

The output file.

options may contain the following key:

:hint

Specifies wether to add hints for QuickTime plugins to the output file.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/rtranscoder/mpeg4ip/mp4creator.rb', line 55

def mux(options={})
  if File.file?(options[:output])
    File.delete(options[:output])
  end

  create do |mp4creator|
    mp4creator.create = options[:audio]
    mp4creator.file = options[:output]
  end

  create do |mp4creator|
    mp4creator.create = options[:video]
    mp4creator.rate = options[:frame_rate].to_f
    mp4creator.file = options[:output]
  end

  if options[:hint]
    create do |mp4creator|
      mp4creator.hint = 1
      mp4creator.file = options[:output]
    end

    create do |mp4creator|
      mp4creator.hint = 2
      mp4creator.file = options[:output]
    end

    create do |mp4creator|
      mp4creator.optimize = true
      mp4creator.file = options[:output]
    end
  end
end