Module: FFMpeg

Includes:
AudioOptions, HelperMethods, MainOptions, MetaData, VideoAdvancedOptions, VideoOptions
Defined in:
lib/ffmpeg.rb,
lib/ffmpeg/meta_data.rb,
lib/ffmpeg/main_options.rb,
lib/ffmpeg/audio_options.rb,
lib/ffmpeg/class_methods.rb,
lib/ffmpeg/video_options.rb,
lib/ffmpeg/helper_methods.rb,
lib/ffmpeg/video_advanced_options.rb

Defined Under Namespace

Modules: AudioOptions, ClassMethods, HelperMethods, MainOptions, MetaData, VideoAdvancedOptions, VideoOptions

Constant Summary

Constants included from MetaData

MetaData::EXIF_UTILITY

Class Method Summary collapse

Instance Method Summary collapse

Methods included from MetaData

#meta

Methods included from AudioOptions

#audio_bitrate, #audio_channels, #audio_codec, #audio_frames, #audio_language, #audio_sampling, #disable_audio, #new_audio

Methods included from VideoAdvancedOptions

#b_frame_factor, #b_frame_offset, #b_frames, #calculate_psnr, #dct_algorithm, #deinterlace, #dump_video_statistics, #enable_advanced_intra_coding, #enable_unlimited_motion_vector, #error_concealment, #error_resilience, #group_of_pictures_size, #i_frame_factor, #i_frame_offset, #idct_algorithm, #initial_complexity, #interlacing_support, #macroblock_decision_mode, #motion_estimation_method, #pixel_format, #rate_control_equation, #rate_control_override, #show_qp_histogram, #strictness, #swscaler_flags, #use_data_partitioning, #use_four_motion_vector, #use_only_intra_frames, #video_bitstream_filter, #video_discard_threshold, #video_maximum_lagrange_factor, #video_maximum_macroblock_scale, #video_maximum_quantizer_difference, #video_maximum_quantizer_scale, #video_minimum_lagrange_factor, #video_minimum_macroblock_scale, #video_minimum_quantizer_scale, #video_quantizer_scale, #video_quantizer_scale_blur, #video_quantizer_scale_compression

Methods included from VideoOptions

#aspect, #crop_bottom, #crop_left, #crop_right, #crop_top, #disable_video, #framerate, #new_video, #pad_bottom, #pad_color, #pad_left, #pad_right, #pad_top, #resolution, #same_video_quality, #video_bitrate, #video_bitrate_tolerance, #video_buffer_size, #video_codec, #video_frames, #video_maximum_bitrate, #video_minimum_bitrate, #video_pass, #video_pass_logfile

Methods included from MainOptions

#album, #author, #comment, #copyright, #duration, #file_size_limit, #frames_to_record, #offset, #overwrite_existing_file, #seek, #source, #subtitle_codec, #target, #title, #track, #year

Methods included from HelperMethods

#returning

Class Method Details

.included(klass) ⇒ Object

When mixed into a class, extend

it with the ClassMethods module



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ffmpeg.rb', line 23

def self.included(klass)
  klass.extend ClassMethods
  
  #
  # Everytime a method is added to the
  # class, check for conflicts with existing
  # module methods
  #
  def klass.method_added(name)
    check_method(name) if method_checking_enabled?
  end
end

Instance Method Details

#convert(from_file, to_file = {}) ⇒ Object

Sets up an FFmpegCommand for converting files:

convert "file1.ext", :to => "file2.ext" do
  seek       "00:03:00"
  duration   "01:10:00"
  resolution "800x600"
end


45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/ffmpeg.rb', line 45

def convert(from_file, to_file = {})
  @from_file = from_file
  FFMpegCommand << "-i #{from_file}"
  begin
    yield if block_given?
  rescue Exception => exception
    disable_method_checking!
    raise exception
  end
  
  build_output_file_name(from_file, to_file[:to]) do |file_name|
    FFMpegCommand << file_name
  end
end

#ffmpeg_path(path) ⇒ Object

Explicitly set ffmpeg path



63
64
65
# File 'lib/ffmpeg.rb', line 63

def ffmpeg_path(path)
  @@ffmpeg_path = path
end

#runObject

Runs ffmpeg



70
71
72
73
74
75
76
77
78
# File 'lib/ffmpeg.rb', line 70

def run
  @@ffmpeg_path ||= locate_ffmpeg
  unless @@ffmpeg_path.empty?
    execute_command FFMpegCommand.command(@@ffmpeg_path)
  else
    $stderr.puts "Couldn't locate ffmpeg, try to specify an explicit path
                  with the ffmpeg_path(path) method"
  end
end