Class: RTranscoder::FFmpeg
- Inherits:
-
RProgram::Program
- Object
- RProgram::Program
- RTranscoder::FFmpeg
- Defined in:
- lib/rtranscoder/ffmpeg/ffmpeg.rb
Class Method Summary collapse
-
.encode(options = {}, &block) ⇒ Object
See FFmpeg#encode.
-
.thumbnail(options = {}) ⇒ Object
See FFmpeg#thumbnail.
Instance Method Summary collapse
-
#encode(options = {}, &block) ⇒ Object
Runs the
ffmpeg
program with the given options and the given block using FFmpegTask. -
#initialize(path) ⇒ FFmpeg
constructor
Creates a new FFmpeg object with the specified path of the
ffmpeg
program. -
#thumbnail(options = {}) ⇒ Object
Extracts a thumbnail using the given options.
Constructor Details
#initialize(path) ⇒ FFmpeg
Creates a new FFmpeg object with the specified path of the ffmpeg
program.
15 16 17 |
# File 'lib/rtranscoder/ffmpeg/ffmpeg.rb', line 15 def initialize(path) super(path) end |
Class Method Details
.encode(options = {}, &block) ⇒ Object
See FFmpeg#encode.
22 23 24 |
# File 'lib/rtranscoder/ffmpeg/ffmpeg.rb', line 22 def self.encode(={},&block) self.find.encode(,&block) end |
.thumbnail(options = {}) ⇒ Object
See FFmpeg#thumbnail.
29 30 31 |
# File 'lib/rtranscoder/ffmpeg/ffmpeg.rb', line 29 def self.thumbnail(={}) self.find.thumbnail() end |
Instance Method Details
#encode(options = {}, &block) ⇒ Object
Runs the ffmpeg
program with the given options and the given block using FFmpegTask.
37 38 39 |
# File 'lib/rtranscoder/ffmpeg/ffmpeg.rb', line 37 def encode(={},&block) run_task(FFmpegTask.new(,&block)) end |
#thumbnail(options = {}) ⇒ Object
Extracts a thumbnail using the given options.
options may contain the following keys:
:video
-
The input video file.
:start
-
The start timestamp of the thumbnail.
:length
-
The duration time of the thumbnail.
:frames
-
Number of video frames to record.
:fps
-
The FPS to use, defaults to 1.
:width
-
The width of the thumbnail.
:height
-
The height of the thumbnail.
:image
-
The output thumbnail image.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/rtranscoder/ffmpeg/ffmpeg.rb', line 54 def thumbnail(={}) image = File.([:image]) encode do |ffmpeg| ffmpeg.input = [:video] ffmpeg.record_start_time = [:start] ffmpeg.record_for = [:length] ffmpeg.video_frames = [:frames] ffmpeg.fps = ([:fps] || 1) ffmpeg.video_frame_size = "#{[:width]}x#{[:height]}" ffmpeg.disable_audio = true ffmpeg.overwrite_output_files = true ffmpeg.output = image end image_search = image.split('%d').map { |part| Regexp.escape(part) }.join('*') return Dir[image_search] end |