Module: FFMPEG
- Defined in:
- lib/ffmpeg/movie.rb,
lib/ffmpeg/errors.rb,
lib/ffmpeg/version.rb,
lib/streamio-ffmpeg.rb,
lib/ffmpeg/transcoder.rb,
lib/ffmpeg/encoding_options.rb
Defined Under Namespace
Classes: EncodingOptions, Error, HTTPTooManyRequests, Movie, Transcoder
Constant Summary collapse
- VERSION =
'3.0.2'
Class Method Summary collapse
-
.ffmpeg_binary ⇒ String
Get the path to the ffmpeg binary, defaulting to ‘ffmpeg’.
-
.ffmpeg_binary=(bin) ⇒ String
Set the path of the ffmpeg binary.
-
.ffprobe_binary ⇒ String
Get the path to the ffprobe binary, defaulting to what is on ENV.
-
.ffprobe_binary=(bin) ⇒ String
Set the path of the ffprobe binary.
-
.logger ⇒ Logger
Get FFMPEG logger.
-
.logger=(log) ⇒ Logger
FFMPEG logs information about its progress when it’s transcoding.
-
.max_http_redirect_attempts ⇒ Integer
Get the maximum number of http redirect attempts.
-
.max_http_redirect_attempts=(v) ⇒ Integer
Set the maximum number of http redirect attempts.
-
.which(cmd) ⇒ Object
Cross-platform way of finding an executable in the $PATH.
Class Method Details
.ffmpeg_binary ⇒ String
Get the path to the ffmpeg binary, defaulting to ‘ffmpeg’
50 51 52 |
# File 'lib/streamio-ffmpeg.rb', line 50 def self.ffmpeg_binary @ffmpeg_binary || which('ffmpeg') end |
.ffmpeg_binary=(bin) ⇒ String
Set the path of the ffmpeg binary. Can be useful if you need to specify a path such as /usr/local/bin/ffmpeg
39 40 41 42 43 44 |
# File 'lib/streamio-ffmpeg.rb', line 39 def self.ffmpeg_binary=(bin) if bin.is_a?(String) && !File.executable?(bin) raise Errno::ENOENT, "the ffmpeg binary, \'#{bin}\', is not executable" end @ffmpeg_binary = bin end |
.ffprobe_binary ⇒ String
Get the path to the ffprobe binary, defaulting to what is on ENV
58 59 60 |
# File 'lib/streamio-ffmpeg.rb', line 58 def self.ffprobe_binary @ffprobe_binary || which('ffprobe') end |
.ffprobe_binary=(bin) ⇒ String
Set the path of the ffprobe binary. Can be useful if you need to specify a path such as /usr/local/bin/ffprobe
68 69 70 71 72 73 |
# File 'lib/streamio-ffmpeg.rb', line 68 def self.ffprobe_binary=(bin) if bin.is_a?(String) && !File.executable?(bin) raise Errno::ENOENT, "the ffprobe binary, \'#{bin}\', is not executable" end @ffprobe_binary = bin end |
.logger ⇒ Logger
Get FFMPEG logger.
26 27 28 29 30 31 |
# File 'lib/streamio-ffmpeg.rb', line 26 def self.logger return @logger if @logger logger = Logger.new(STDOUT) logger.level = Logger::INFO @logger = logger end |
.logger=(log) ⇒ Logger
FFMPEG logs information about its progress when it’s transcoding. Jack in your own logger through this method if you wish to.
19 20 21 |
# File 'lib/streamio-ffmpeg.rb', line 19 def self.logger=(log) @logger = log end |
.max_http_redirect_attempts ⇒ Integer
Get the maximum number of http redirect attempts
78 79 80 |
# File 'lib/streamio-ffmpeg.rb', line 78 def self.max_http_redirect_attempts @max_http_redirect_attempts.nil? ? 10 : @max_http_redirect_attempts end |
.max_http_redirect_attempts=(v) ⇒ Integer
Set the maximum number of http redirect attempts.
87 88 89 90 91 |
# File 'lib/streamio-ffmpeg.rb', line 87 def self.max_http_redirect_attempts=(v) raise Errno::ENOENT, 'max_http_redirect_attempts must be an integer' if v && !v.is_a?(Integer) raise Errno::ENOENT, 'max_http_redirect_attempts may not be negative' if v && v < 0 @max_http_redirect_attempts = v end |
.which(cmd) ⇒ Object
Cross-platform way of finding an executable in the $PATH.
which('ruby') #=> /usr/bin/ruby
see: stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/streamio-ffmpeg.rb', line 97 def self.which(cmd) exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| exts.each { |ext| exe = File.join(path, "#{cmd}#{ext}") return exe if File.executable? exe } end raise Errno::ENOENT, "the #{cmd} binary could not be found in #{ENV['PATH']}" end |