Module: Hydra::Derivatives::Ffmpeg
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/hydra/derivatives/ffmpeg.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
Instance Method Details
#encode_datastream(dest_dsid, file_suffix, mime_type, options = '') ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/hydra/derivatives/ffmpeg.rb', line 25 def encode_datastream(dest_dsid, file_suffix, mime_type, = '') out_file = nil output_file = Dir::Tmpname.create(['sufia', ".#{file_suffix}"], Hydra::Derivatives.temp_file_base){} source_datastream.to_tempfile do |f| self.class.encode(f.path, , output_file) end out_file = File.open(output_file, "rb") object.add_file_datastream(out_file.read, :dsid=>dest_dsid, :mimeType=>mime_type) File.unlink(output_file) end |
#process ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/hydra/derivatives/ffmpeg.rb', line 15 def process directives.each do |name, args| format = args[:format] raise ArgumentError, "You must provide the :format you want to transcode into. You provided #{args}" unless format # TODO if the source is in the correct format, we could just copy it and skip transcoding. output_datastream_name = args[:datastream] || output_datastream_id(name) encode_datastream(output_datastream_name, format, new_mime_type(format), (format)) end end |