class Transcode < XMorph::Base DEFAULT_COMMAND = "DEFAULT_COMMAND" def set_profiles self.profiles = { DEFAULT_COMMAND => "docker run --rm -v %{IP_MOUNT_PATH}:%{IP_MOUNT_PATH} -v %{OP_MOUNT_PATH}:%{OP_MOUNT_PATH} %{VOLT_TAG} ./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