Sha256: 8b5f9e02d9eb33a819f21bb03e4579ac7b5309787f30d94f1f3d7034b903cbba

Contents?: true

Size: 944 Bytes

Versions: 6

Compression:

Stored size: 944 Bytes

Contents

# Created by: Justin Coyne
# 7 Feb 2013
# An asyncronous job for transcoding audio files using FFMpeg

class TranscodeAudioJob < FfmpegTranscodeJob
  def queue_name
    :audio
  end

  def process
    encode_mp3()
    encode_ogg()
  end

  private 
    def encode_ogg
      opts = ""
      if generic_file.mime_type == 'audio/ogg'
        # Don't re-encode, just copy
        generic_file.add_file_datastream(generic_file.content.read, :dsid=>'ogg', :mimeType=>'audio/ogg')
        #generic_file.content.rewind
      else
        encode_datastream('ogg', 'audio/ogg', opts)
      end
    end

    def encode_mp3
      opts = ""
      if generic_file.mime_type == 'audio/mpeg'
        # Don't re-encode, just copy
        generic_file.add_file_datastream(generic_file.content.read, :dsid=>'mp3', :mimeType=>'audio/mp3')
        #generic_file.content.rewind
      else
        encode_datastream('mp3', 'audio/mp3', opts)
      end
    end


end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
sufia-models-0.1.0 lib/sufia/models/jobs/transcode_audio_job.rb
sufia-models-0.0.2 lib/sufia/models/jobs/transcode_audio_job.rb
sufia-models-0.0.1 lib/sufia/models/jobs/transcode_audio_job.rb
sufia-1.2.0 lib/sufia/jobs/transcode_audio_job.rb
sufia-1.1.0 lib/sufia/jobs/transcode_audio_job.rb
sufia-1.0.0 lib/sufia/jobs/transcode_audio_job.rb