lib/active_encode/engine_adapters/media_convert_adapter.rb
# [AWS Elemental MediaConvert](https://aws.amazon.com/mediaconvert/) doesn't provide detailed
# output information in the job description that can be pulled directly from the service.
# Instead, it provides that information along with the job status notification when the job
# status changes to `COMPLETE`. The only way to capture that notification is through an [Amazon
# Eventbridge](https://aws.amazon.com/eventbridge/) rule that forwards the status change
# notification to another service for capture and/or handling.
#
# `ActiveEncode::EngineAdapters::MediaConvert` does this by creating a [CloudWatch Logs]
# (https://aws.amazon.com/cloudwatch/) log group and an EventBridge rule to forward status
# change notifications to the log group. It can then find the log entry containing the output
# details later when the job is complete. This is accomplished by calling the idempotent
# `#setup!` method.
#
# The AWS user/role calling the `#setup!` method will require permissions to create the
# necessary CloudWatch and EventBridge resources, and the role passed to the engine adapter
# will need access to any S3 buckets where files will be read from or written to during
# transcoding.
#
# Configuration example:
#
#     ActiveEncode::Base.engine_adapter = :media_convert
#     ActiveEncode::Base.engine_adapter.role = 'arn:aws:iam::123456789012:role/service-role/MediaConvert_Default_Role'
#     ActiveEncode::Base.engine_adapter.output_bucket = 'output-bucket'
#     ActiveEncode::Base.engine_adapter.setup!
[AWS Elemental MediaConvert] doesn't provide detailed
output information in the job description that can be pulled directly from the service.
Instead, it provides that information along with the job status notification when the job
status changes to `COMPLETE`. The only way to capture that notification is through an [Amazon
Eventbridge] rule that forwards the status change
notification to another service for capture and/or handling.

`ActiveEncode::EngineAdapters::MediaConvert` does this by creating a [CloudWatch Logs]
log group and an EventBridge rule to forward status
change notifications to the log group. It can then find the log entry containing the output
details later when the job is complete. This is accomplished by calling the idempotent
`#setup!` method.

The AWS user/role calling the `#setup!` method will require permissions to create the
necessary CloudWatch and EventBridge resources, and the role passed to the engine adapter
will need access to any S3 buckets where files will be read from or written to during
transcoding.

Configuration example.


[ AWS Elemental MediaConvert ] doesn ' t provide detailed output information in the job description that can be pulled directly from the service . Instead it provides that information along with the job status notification when the job status changes to ` COMPLETE ` . The only way to capture that notification is through an [ Amazon Eventbridge ] rule that forwards the status change notification to another service for capture and / or handling . ` ActiveEncode :: EngineAdapters :: MediaConvert ` does this by creating a [ CloudWatch Logs ] log group and an EventBridge rule to forward status change notifications to the log group . It can then find the log entry containing the output details later when the job is complete . This is accomplished by calling the idempotent ` #setup! ` method . The AWS user / role calling the ` #setup! ` method will require permissions to create the necessary CloudWatch and EventBridge resources and the role passed to the engine adapter will need access to any S3 buckets where files will be read from or written to during transcoding . Configuration example .
def convert_encode_results(job, results)
          settings = job.settings.output_groups.first.outputs
          outputs = results.dig('detail', 'outputGroupDetails', 0, 'outputDetails').map.with_index do |detail, index|
            tech_md = MediaConvertOutput.tech_metadata(settings[index], detail)
            output = ActiveEncode::Output.new
            output.created_at = job.timing.submit_time
            output.updated_at = job.timing.finish_time || job.timing.start_time || output.created_at
            [:width, :height, :frame_rate, :duration, :checksum, :audio_codec, :video_codec,
             :audio_bitrate, :video_bitrate, :file_size, :label, :url, :id].each do |field|
              output.send("#{field}=", tech_md[field])
            end
            output.id ||= "#{job.id}-output#{tech_md[:suffix]}"
            output
          end
          adaptive_playlist = results.dig('detail', 'outputGroupDetails', 0, 'playlistFilePaths', 0)
          unless adaptive_playlist.nil?
            output = ActiveEncode::Output.new
            output.created_at = job.timing.submit_time
            output.updated_at = job.timing.finish_time || job.timing.start_time || output.created_at
            output.id = "#{job.id}-output-auto"
            [:duration, :audio_codec, :video_codec].each do |field|
              output.send("#{field}=", outputs.first.send(field))
            end
            output.label = File.basename(adaptive_playlist)
            output.url = adaptive_playlist
            outputs << output
          end
          outputs
        end
def convert_encode_results ( job , results ) settings = job . settings . output_groups . first . outputs outputs = results . dig ( 'detail' , 'outputGroupDetails' , 0 , 'outputDetails' ) . map . with_index do | detail , index | tech_md = MediaConvertOutput . tech_metadata ( settings [ index ] , detail ) output = ActiveEncode :: Output . new output . created_at = job . timing . submit_time output . updated_at = job . timing . finish_time || job . timing . start_time || output . created_at [ :width , :height , :frame_rate , :duration , :checksum , :audio_codec , :video_codec , :audio_bitrate , :video_bitrate , :file_size , :label , :url , :id ] . each do | field | output . send ( "#{field}=" , tech_md [ field ] ) end output . id ||= "#{job.id}-output#{tech_md[:suffix]}" output end adaptive_playlist = results . dig ( 'detail' , 'outputGroupDetails' , 0 , 'playlistFilePaths' , 0 ) unless adaptive_playlist . nil? output = ActiveEncode :: Output . new output . created_at = job . timing . submit_time output . updated_at = job . timing . finish_time || job . timing . start_time || output . created_at output . id = "#{job.id}-output-auto" [ :duration , :audio_codec , :video_codec ] . each do | field | output . send ( "#{field}=" , outputs . first . send ( field ) ) end output . label = File . basename ( adaptive_playlist ) output . url = adaptive_playlist outputs << output end outputs end
[AWS Elemental MediaConvert](https://aws.amazon.com/mediaconvert/) doesn't provide detailed
output information in the job description that can be pulled directly from the service.
[ AWS Elemental MediaConvert ] ( https : // aws . amazon . com / mediaconvert / ) doesn ' t provide detailed output information in the job description that can be pulled directly from the service .
job
<not_specific>
results
<not_specific>