Sha256: 8457e79b91ca863cd10f66521caa5fa57b8304e74d9ffd6951389632eee394b6

Contents?: true

Size: 1.7 KB

Versions: 1

Compression:

Stored size: 1.7 KB

Contents

class Transcode < XMorph::Base

  DEFAULT_COMMAND = "DEFAULT_COMMAND"

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

  def video_checks
    {
      ALLOWED_ASPECT_RATIO => ["16:9"],
      ALLOWED_HEIGHT => [1080],
      ALLOWED_WIDTH => [1440, 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

  def set_profile_name
    self.profile_name = nil
    self.error = nil

    audio_tracks = self.mediainfo_output["Audio"]
    sample_rate = audio_tracks.map{|a| a["Sampling_rate"]}
    self.error = "Unexpected audio sample rate #{sample_rate.uniq}. We support 48.0 KHz" and return  if sample_rate.uniq != ["48.0 KHz"]

    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 and number_of_audio_channels.uniq == [1]) or (number_of_audio_tracks == 1 and number_of_audio_channels.uniq == [2])
      self.profile_name = DEFAULT_COMMAND
      return true
    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.13 lib/xmorph/customers/cbn/cbn/transcode.rb