Sha256: 39a63deca77e5da8e996195d2ac22af3498c9f6ef5107c4f200dab1a2f69eeb8

Contents?: true

Size: 1.94 KB

Versions: 1

Compression:

Stored size: 1.94 KB

Contents

class Transcode < XMorph::Base

  MONO_STEREO = "mono_stereo"
  def set_profiles
    self.profiles = {
      MONO_STEREO => "docker run --rm -v /tmp:/tmp amagidevops/volt:mr_2.1.8 ./volt/transcoder -if %{IN} -of %{OUT} -vr 1080i60 -acm \"1,2\" -ac \"ac3\" -ac3_dialnorm -24 -lt -25 -lm DOLBY", #FFMPEG-NORM
    }
  end

  def video_checks
    {
      ALLOWED_ASPECT_RATIO => ["16:9"],
      ALLOWED_HEIGHT => [1080],
      ALLOWED_WIDTH => [1920], 
      ALLOWED_FRAME_RATE => [29.97],
      ALLOWED_VIDEO_BIT_RATE => IGNORE, #Mbps
      ALLOWED_SCAN_TYPE => ["interlaced"], #all downcased
    }
  end

  def audio_checks
    {
      PRESENCE_OF_AUDIO_TRACK => VALIDATE,
      ALLOWED_NUMBER_OF_AUDIO_TRACKS => [1, 2],
      ALLOWED_AUDIO_CODECS => ["pcm"],
      ALLOWED_AUDIO_BIT_RATE => IGNORE, #kbps
      ALLOWED_NUMBER_OF_AUDIO_CHANNELS => [1, 2],
    }
  end

  # Classification is based on number of channels
  def set_profile_name
    self.profile_name = nil
    self.error = nil

    mediainfo = self.mediainfo_output
    audio_tracks = mediainfo["Audio"]

    number_of_audio_tracks = audio_tracks.count
    number_of_audio_channels = audio_tracks.map{|a| a["Channel_s_"].split(" ")[0].to_i if a["Channel_s_"].present?}

    if number_of_audio_tracks == 2 
      if number_of_audio_channels.uniq == [1]
        self.profile_name = MONO_STEREO
      else 
        self.error = "Got unexpected number of audio channels #{number_of_audio_channels} for #{number_of_audio_tracks} tracks, we support mono.}"
      end
    elsif number_of_audio_tracks == 1
      if number_of_audio_channels.uniq == [2]
        self.profile_name = MONO_STEREO
      else
        self.error = "Got unexpected number of audio channels #{number_of_audio_channels} for #{number_of_audio_tracks} tracks, we support stereo.}"
      end
    end
    
    XMorph::Base.logger.debug("XMorph#set_profile_name#CBN: using profile #{self.profile_name}") unless self.profile_name.nil?
    return true
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xmorph-0.1.5 lib/xmorph/customers/cbn/cbn/transcode.rb