Module: CarrierWave::Video
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/carrierwave/video.rb,
lib/carrierwave/video/ffmpeg_theora.rb,
lib/carrierwave/video/ffmpeg_options.rb
Defined Under Namespace
Modules: ClassMethods
Classes: FfmpegOptions, FfmpegTheora
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.ffmpeg2theora_binary ⇒ Object
13
14
15
|
# File 'lib/carrierwave/video.rb', line 13
def self.ffmpeg2theora_binary
@ffmpeg2theora.nil? ? 'ffmpeg2theora' : @ffmpeg2theora
end
|
.ffmpeg2theora_binary=(bin) ⇒ Object
9
10
11
|
# File 'lib/carrierwave/video.rb', line 9
def self.ffmpeg2theora_binary=(bin)
@ffmpeg2theora = bin
end
|
Instance Method Details
#encode_ogv(opts) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/carrierwave/video.rb', line 28
def encode_ogv(opts)
cache_stored_file! if !cached?
tmp_path = File.join( File.dirname(current_path), "tmpfile.ogv" )
@options = CarrierWave::Video::FfmpegOptions.new('ogv', opts)
with_trancoding_callbacks do
transcoder = CarrierWave::Video::FfmpegTheora.new(current_path, tmp_path)
transcoder.run(@options.logger(model))
File.rename tmp_path, current_path
end
end
|
#encode_video(format, opts = {}) {|file, @options.format_options| ... } ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/carrierwave/video.rb', line 42
def encode_video(format, opts={})
cache_stored_file! if !cached?
@options = CarrierWave::Video::FfmpegOptions.new(format, opts)
tmp_path = File.join( File.dirname(current_path), "tmpfile.#{format}" )
file = ::FFMPEG::Movie.new(current_path)
if opts[:resolution] == :same
@options.format_options[:resolution] = file.resolution
end
yield(file, @options.format_options) if block_given?
progress = @options.progress(model)
with_trancoding_callbacks do
if progress
file.transcode(tmp_path, @options.format_params, @options.encoder_options) {
|value| progress.call(value)
}
else
file.transcode(tmp_path, @options.format_params, @options.encoder_options)
end
File.rename tmp_path, current_path
end
end
|