Class: FFmpegCore::Movie
- Inherits:
-
Object
- Object
- FFmpegCore::Movie
- Extended by:
- Forwardable
- Defined in:
- lib/ffmpeg_core/movie.rb
Overview
Modern API for working with video files
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#probe ⇒ Object
readonly
Returns the value of attribute probe.
Instance Method Summary collapse
-
#cut(output_path, options = {}) ⇒ String
Cut/trim a segment from video.
-
#extract_audio(output_path, options = {}) ⇒ String
Extract audio track from video.
-
#initialize(path) ⇒ Movie
constructor
A new instance of Movie.
-
#screenshot(output_path, options = {}) ⇒ String
Extract screenshot from video.
-
#screenshots(output_dir, count: 5) ⇒ Array<String>
Extract multiple screenshots at equal intervals.
-
#transcode(output_path, options = {}) {|Float| ... } ⇒ String
Transcode video with modern API.
Constructor Details
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/ffmpeg_core/movie.rb', line 8 def path @path end |
#probe ⇒ Object (readonly)
Returns the value of attribute probe.
8 9 10 |
# File 'lib/ffmpeg_core/movie.rb', line 8 def probe @probe end |
Instance Method Details
#cut(output_path, options = {}) ⇒ String
Cut/trim a segment from video
64 65 66 67 |
# File 'lib/ffmpeg_core/movie.rb', line 64 def cut(output_path, = {}) clipper = Clipper.new(path, output_path, ) clipper.run end |
#extract_audio(output_path, options = {}) ⇒ String
Extract audio track from video
75 76 77 78 |
# File 'lib/ffmpeg_core/movie.rb', line 75 def extract_audio(output_path, = {}) extractor = AudioExtractor.new(path, output_path, ) extractor.run end |
#screenshot(output_path, options = {}) ⇒ String
Extract screenshot from video
51 52 53 54 |
# File 'lib/ffmpeg_core/movie.rb', line 51 def screenshot(output_path, = {}) screenshotter = Screenshot.new(path, output_path, ) screenshotter.extract end |
#screenshots(output_dir, count: 5) ⇒ Array<String>
Extract multiple screenshots at equal intervals
85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/ffmpeg_core/movie.rb', line 85 def screenshots(output_dir, count: 5) FileUtils.mkdir_p(output_dir) total = duration || 0 interval = total / (count + 1).to_f (1..count).map do |i| seek = (interval * i).round(2) output_path = File.join(output_dir, format("screenshot_%03d.jpg", i)) Screenshot.new(path, output_path, seek_time: seek).extract output_path end end |
#transcode(output_path, options = {}) {|Float| ... } ⇒ String
Transcode video with modern API
35 36 37 38 39 40 41 |
# File 'lib/ffmpeg_core/movie.rb', line 35 def transcode(output_path, = {}, &block) # Inject duration for progress calculation if known [:duration] ||= duration transcoder = Transcoder.new(path, output_path, ) transcoder.run(&block) end |