def lambda_handler(self, event, context):
# Loop through records provided by S3 Event trigger
self.logger.info("Working on bucket-key in S3...")
# Extract the Key and Bucket names for the asset uploaded to S3
key = event['key']
bucket = event['bucket']
self.logger.info("Bucket: {} \t Key: {}".format(bucket, key))
# Generate a signed URL for the uploaded asset
signed_url = self.get_signed_url(self.SIGNED_URL_EXPIRATION, bucket, key)
self.logger.info("Signed URL: {}".format(signed_url))
# Launch MediaInfo
# Pass the signed URL of the uploaded asset to MediaInfo as an input
# MediaInfo will extract the technical metadata from the asset
# The extracted metadata will be outputted in XML format and
# stored in the variable xml_output
xml_output = subprocess.check_output(["mediainfo", "--full", "--output=XML", signed_url])
self.logger.info("Output: {}".format(xml_output))
xml_json = xmltodict.parse(xml_output)
return self.write_job_spec_to_file(xml_json, bucket, key)
评论列表
文章目录