将 AWS MediaConvert 作业模板输出到同一目录
Have an AWS MediaConvert job template output to the same directory
我正在尝试在 Amazon 的 MediaConvert 服务中设置一个作业,该服务会将我上传到 S3 存储桶的任何视频转换为适合流式传输的格式。在大多数情况下,这似乎是可行的 - 每次我上传视频时,我的应用程序都会调用 API 到 运行 作业。
但是,为了方便(更容易找到特定文件的输出),我想将输出文件放在与输入文件相同的目录中。
有没有办法将作业模板的输出设置为相对于输入的路径?或者,是否可以覆盖输出目录 而 不必在 Java 代码中从头开始定义整个作业?
这就是我在 Java API:
中设置输入目录的方式
CreateJobRequest request = CreateJobRequest.builder()
.role(roleName)
.jobTemplate("Process uploaded videos") // Matches a custom template I made in AWS
.settings(JobSettings.builder()
.inputs(Input.builder()
.fileInput("s3://" + mConfig.bucket + "/" + mFolder + filename)
.build())
.build())
.build();
指定输出路径的更新版本:
CreateJobRequest request = CreateJobRequest.builder()
.role(MEDIACONVERT_ROLE)
.jobTemplate("Process uploaded videos") // Matches a custom template I made in AWS
.settings(JobSettings.builder()
.inputs(Input.builder()
.fileInput("s3://" + mConfig.bucket + "/" + mFolder + filename)
.build())
.outputGroups(OutputGroup.builder()
.name("Streaming video") // Matches the name of the output group in the template
.outputGroupSettings(OutputGroupSettings.builder()
.type(OutputGroupType.FILE_GROUP_SETTINGS)
.fileGroupSettings(FileGroupSettings.builder()
.destination("s3://" + mConfig.bucket + "/" + mFolder) // Put output in the same folder as the input
.build())
.build())
.build())
.build())
.build();
AWS Elemental MediaConvert 中没有用于根据输入位置为输出设置相对路径的本机方法,但是您是对的,因为您可以覆盖模板中的参数而无需定义整个作业从零开始。
例如,这是一个使用不引用预设的模板提交作业的 AWS CLI (boto3) JSON示例。
注意:此模板包含一个输入数组对象(注意没有 FileURI 参数,您将在创建作业时添加它)
{
"Queue": "arn:aws:mediaconvert:us-west-2:111122223333:queues/Default",
"Name": "Test_MP4",
"Description":"Test MP4"
"Settings": {
"OutputGroups": [
{
"Name": "File Group",
"Outputs": [
{
"ContainerSettings": {
"Container": "MP4",
"Mp4Settings": {
"CslgAtom": "EXCLUDE",
"FreeSpaceBox": "EXCLUDE",
"MoovPlacement": "NORMAL"
}
},
"VideoDescription": {
"Width": 3840,
"ScalingBehavior": "DEFAULT",
"Height": 2160,
"VideoPreprocessors": {
"Deinterlacer": {
"Algorithm": "INTERPOLATE",
"Mode": "DEINTERLACE",
"Control": "NORMAL"
}
},
"TimecodeInsertion": "DISABLED",
"AntiAlias": "ENABLED",
"Sharpness": 50,
"CodecSettings": {
"Codec": "H_265",
"H265Settings": {
"InterlaceMode": "PROGRESSIVE",
"ParNumerator": 1,
"NumberReferenceFrames": 3,
"FramerateDenominator": 1001,
"GopClosedCadence": 1,
"AlternateTransferFunctionSei": "DISABLED",
"HrdBufferInitialFillPercentage": 90,
"GopSize": 48,
"Slices": 4,
"GopBReference": "ENABLED",
"HrdBufferSize": 20000000,
"SlowPal": "DISABLED",
"ParDenominator": 1,
"SpatialAdaptiveQuantization": "ENABLED",
"TemporalAdaptiveQuantization": "ENABLED",
"FlickerAdaptiveQuantization": "DISABLED",
"Bitrate": 10000000,
"FramerateControl": "SPECIFIED",
"RateControlMode": "CBR",
"CodecProfile": "MAIN_MAIN",
"Tiles": "ENABLED",
"Telecine": "NONE",
"FramerateNumerator": 24000,
"MinIInterval": 0,
"AdaptiveQuantization": "HIGH",
"CodecLevel": "LEVEL_5",
"SceneChangeDetect": "ENABLED",
"QualityTuningLevel": "MULTI_PASS_HQ",
"FramerateConversionAlgorithm": "DUPLICATE_DROP",
"UnregisteredSeiTimecode": "DISABLED",
"GopSizeUnits": "FRAMES",
"ParControl": "SPECIFIED",
"NumberBFramesBetweenReferenceFrames": 3,
"TemporalIds": "DISABLED",
"SampleAdaptiveOffsetFilterMode": "ADAPTIVE"
}
},
"AfdSignaling": "NONE",
"DropFrameTimecode": "ENABLED",
"RespondToAfd": "NONE",
"ColorMetadata": "INSERT"
},
"AudioDescriptions": [
{
"AudioTypeControl": "FOLLOW_INPUT",
"CodecSettings": {
"Codec": "AAC",
"AacSettings": {
"AudioDescriptionBroadcasterMix": "NORMAL",
"Bitrate": 160000,
"RateControlMode": "CBR",
"CodecProfile": "LC",
"CodingMode": "CODING_MODE_2_0",
"RawFormat": "NONE",
"SampleRate": 48000,
"Specification": "MPEG4"
}
},
"LanguageCodeControl": "FOLLOW_INPUT",
"AudioType": 0
}
],
"NameModifier": "_1"
}
],
"OutputGroupSettings": {
"Type": "FILE_GROUP_SETTINGS",
"FileGroupSettings": {
"Destination": "s3://myawsbucket/out/"
}
}
}
],
"AdAvailOffset": 0,
"Inputs": [
{
"AudioSelectors": {
"Audio Selector 1": {
"Offset": 0,
"DefaultSelection": "DEFAULT",
"ProgramSelection": 1
}
},
"VideoSelector": {
"ColorSpace": "FOLLOW"
},
"FilterEnable": "AUTO",
"PsiControl": "USE_PSI",
"FilterStrength": 0,
"DeblockFilter": "DISABLED",
"DenoiseFilter": "DISABLED",
"TimecodeSource": "EMBEDDED"
}
]
}
}
以下 JSON 有效载荷在输入上添加了一个输入和一个字幕选择器,并在输出上添加了一个字幕轨道,并且它更改了输出文件的目标位置。
注意:您需要确保包含作业模板名称以及您希望服务承担的角色(即您在使用 IAM 设置中设置的角色)
{
"Settings": {
"OutputGroups": [
{
"Name": "File Group",
"Outputs": [
{
"CaptionDescriptions": [
{
"DestinationSettings": {
"DestinationType": "EMBEDDED"
},
"CaptionSelectorName": "Captions Selector 1",
"LanguageCode": "ENG"
}
]
}
],
"OutputGroupSettings": {
"Type": "FILE_GROUP_SETTINGS",
"FileGroupSettings": {
"Destination": "s3://myawsbucket/newfolder/out/"
}
}
}
],
"AdAvailOffset": 0,
"Inputs": [
{
"AudioSelectors": {
"Audio Selector 1": {
"Offset": 0,
"DefaultSelection": "DEFAULT",
"ProgramSelection": 1
}
},
"VideoSelector": {
"ColorSpace": "FOLLOW"
},
"FilterEnable": "AUTO",
"PsiControl": "USE_PSI",
"FilterStrength": 0,
"DeblockFilter": "DISABLED",
"DenoiseFilter": "DISABLED",
"TimecodeSource": "EMBEDDED",
"FileInput": "s3://myawsbucket/input/test.mp4",
"CaptionSelectors": {
"Captions Selector 1": {
"SourceSettings": {
"SourceType": "SCC",
"FileSourceSettings": {
"SourceFile": "s3://myawsbucket/input/Captions/SCC/test.scc"
}
}
}
}
}
]
},
"JobTemplate": "Test_MP4",
"Role": "arn:aws:iam::111122223333:role/MediaConvertRole"
}
要仅更改目的地,您可以使用此 JSON:
{
"Settings": {
"OutputGroups": [
{
"OutputGroupSettings": {
"Type": "FILE_GROUP_SETTINGS",
"FileGroupSettings": {
"Destination": "s3://myawsbucket/newfolder/out/"
}
}
}
],
"Inputs": [
{
"FileInput": "s3://myawsbucket/input/test.mp4"
}
]
},
"JobTemplate": "Test_MP4",
"Role": "arn:aws:iam::111122223333:role/MediaConvertRole"
}
我正在尝试在 Amazon 的 MediaConvert 服务中设置一个作业,该服务会将我上传到 S3 存储桶的任何视频转换为适合流式传输的格式。在大多数情况下,这似乎是可行的 - 每次我上传视频时,我的应用程序都会调用 API 到 运行 作业。
但是,为了方便(更容易找到特定文件的输出),我想将输出文件放在与输入文件相同的目录中。
有没有办法将作业模板的输出设置为相对于输入的路径?或者,是否可以覆盖输出目录 而 不必在 Java 代码中从头开始定义整个作业?
这就是我在 Java API:
中设置输入目录的方式CreateJobRequest request = CreateJobRequest.builder()
.role(roleName)
.jobTemplate("Process uploaded videos") // Matches a custom template I made in AWS
.settings(JobSettings.builder()
.inputs(Input.builder()
.fileInput("s3://" + mConfig.bucket + "/" + mFolder + filename)
.build())
.build())
.build();
指定输出路径的更新版本:
CreateJobRequest request = CreateJobRequest.builder()
.role(MEDIACONVERT_ROLE)
.jobTemplate("Process uploaded videos") // Matches a custom template I made in AWS
.settings(JobSettings.builder()
.inputs(Input.builder()
.fileInput("s3://" + mConfig.bucket + "/" + mFolder + filename)
.build())
.outputGroups(OutputGroup.builder()
.name("Streaming video") // Matches the name of the output group in the template
.outputGroupSettings(OutputGroupSettings.builder()
.type(OutputGroupType.FILE_GROUP_SETTINGS)
.fileGroupSettings(FileGroupSettings.builder()
.destination("s3://" + mConfig.bucket + "/" + mFolder) // Put output in the same folder as the input
.build())
.build())
.build())
.build())
.build();
AWS Elemental MediaConvert 中没有用于根据输入位置为输出设置相对路径的本机方法,但是您是对的,因为您可以覆盖模板中的参数而无需定义整个作业从零开始。
例如,这是一个使用不引用预设的模板提交作业的 AWS CLI (boto3) JSON示例。
注意:此模板包含一个输入数组对象(注意没有 FileURI 参数,您将在创建作业时添加它)
{
"Queue": "arn:aws:mediaconvert:us-west-2:111122223333:queues/Default",
"Name": "Test_MP4",
"Description":"Test MP4"
"Settings": {
"OutputGroups": [
{
"Name": "File Group",
"Outputs": [
{
"ContainerSettings": {
"Container": "MP4",
"Mp4Settings": {
"CslgAtom": "EXCLUDE",
"FreeSpaceBox": "EXCLUDE",
"MoovPlacement": "NORMAL"
}
},
"VideoDescription": {
"Width": 3840,
"ScalingBehavior": "DEFAULT",
"Height": 2160,
"VideoPreprocessors": {
"Deinterlacer": {
"Algorithm": "INTERPOLATE",
"Mode": "DEINTERLACE",
"Control": "NORMAL"
}
},
"TimecodeInsertion": "DISABLED",
"AntiAlias": "ENABLED",
"Sharpness": 50,
"CodecSettings": {
"Codec": "H_265",
"H265Settings": {
"InterlaceMode": "PROGRESSIVE",
"ParNumerator": 1,
"NumberReferenceFrames": 3,
"FramerateDenominator": 1001,
"GopClosedCadence": 1,
"AlternateTransferFunctionSei": "DISABLED",
"HrdBufferInitialFillPercentage": 90,
"GopSize": 48,
"Slices": 4,
"GopBReference": "ENABLED",
"HrdBufferSize": 20000000,
"SlowPal": "DISABLED",
"ParDenominator": 1,
"SpatialAdaptiveQuantization": "ENABLED",
"TemporalAdaptiveQuantization": "ENABLED",
"FlickerAdaptiveQuantization": "DISABLED",
"Bitrate": 10000000,
"FramerateControl": "SPECIFIED",
"RateControlMode": "CBR",
"CodecProfile": "MAIN_MAIN",
"Tiles": "ENABLED",
"Telecine": "NONE",
"FramerateNumerator": 24000,
"MinIInterval": 0,
"AdaptiveQuantization": "HIGH",
"CodecLevel": "LEVEL_5",
"SceneChangeDetect": "ENABLED",
"QualityTuningLevel": "MULTI_PASS_HQ",
"FramerateConversionAlgorithm": "DUPLICATE_DROP",
"UnregisteredSeiTimecode": "DISABLED",
"GopSizeUnits": "FRAMES",
"ParControl": "SPECIFIED",
"NumberBFramesBetweenReferenceFrames": 3,
"TemporalIds": "DISABLED",
"SampleAdaptiveOffsetFilterMode": "ADAPTIVE"
}
},
"AfdSignaling": "NONE",
"DropFrameTimecode": "ENABLED",
"RespondToAfd": "NONE",
"ColorMetadata": "INSERT"
},
"AudioDescriptions": [
{
"AudioTypeControl": "FOLLOW_INPUT",
"CodecSettings": {
"Codec": "AAC",
"AacSettings": {
"AudioDescriptionBroadcasterMix": "NORMAL",
"Bitrate": 160000,
"RateControlMode": "CBR",
"CodecProfile": "LC",
"CodingMode": "CODING_MODE_2_0",
"RawFormat": "NONE",
"SampleRate": 48000,
"Specification": "MPEG4"
}
},
"LanguageCodeControl": "FOLLOW_INPUT",
"AudioType": 0
}
],
"NameModifier": "_1"
}
],
"OutputGroupSettings": {
"Type": "FILE_GROUP_SETTINGS",
"FileGroupSettings": {
"Destination": "s3://myawsbucket/out/"
}
}
}
],
"AdAvailOffset": 0,
"Inputs": [
{
"AudioSelectors": {
"Audio Selector 1": {
"Offset": 0,
"DefaultSelection": "DEFAULT",
"ProgramSelection": 1
}
},
"VideoSelector": {
"ColorSpace": "FOLLOW"
},
"FilterEnable": "AUTO",
"PsiControl": "USE_PSI",
"FilterStrength": 0,
"DeblockFilter": "DISABLED",
"DenoiseFilter": "DISABLED",
"TimecodeSource": "EMBEDDED"
}
]
}
}
以下 JSON 有效载荷在输入上添加了一个输入和一个字幕选择器,并在输出上添加了一个字幕轨道,并且它更改了输出文件的目标位置。
注意:您需要确保包含作业模板名称以及您希望服务承担的角色(即您在使用 IAM 设置中设置的角色)
{
"Settings": {
"OutputGroups": [
{
"Name": "File Group",
"Outputs": [
{
"CaptionDescriptions": [
{
"DestinationSettings": {
"DestinationType": "EMBEDDED"
},
"CaptionSelectorName": "Captions Selector 1",
"LanguageCode": "ENG"
}
]
}
],
"OutputGroupSettings": {
"Type": "FILE_GROUP_SETTINGS",
"FileGroupSettings": {
"Destination": "s3://myawsbucket/newfolder/out/"
}
}
}
],
"AdAvailOffset": 0,
"Inputs": [
{
"AudioSelectors": {
"Audio Selector 1": {
"Offset": 0,
"DefaultSelection": "DEFAULT",
"ProgramSelection": 1
}
},
"VideoSelector": {
"ColorSpace": "FOLLOW"
},
"FilterEnable": "AUTO",
"PsiControl": "USE_PSI",
"FilterStrength": 0,
"DeblockFilter": "DISABLED",
"DenoiseFilter": "DISABLED",
"TimecodeSource": "EMBEDDED",
"FileInput": "s3://myawsbucket/input/test.mp4",
"CaptionSelectors": {
"Captions Selector 1": {
"SourceSettings": {
"SourceType": "SCC",
"FileSourceSettings": {
"SourceFile": "s3://myawsbucket/input/Captions/SCC/test.scc"
}
}
}
}
}
]
},
"JobTemplate": "Test_MP4",
"Role": "arn:aws:iam::111122223333:role/MediaConvertRole"
}
要仅更改目的地,您可以使用此 JSON:
{
"Settings": {
"OutputGroups": [
{
"OutputGroupSettings": {
"Type": "FILE_GROUP_SETTINGS",
"FileGroupSettings": {
"Destination": "s3://myawsbucket/newfolder/out/"
}
}
}
],
"Inputs": [
{
"FileInput": "s3://myawsbucket/input/test.mp4"
}
]
},
"JobTemplate": "Test_MP4",
"Role": "arn:aws:iam::111122223333:role/MediaConvertRole"
}