Include_if_source_has
There are times where you want to conditionally include an output track depending on if a particular input track exists in the source. An example of this would be as follows: separate the outputs into a video file and an audio file, but only create the output audio file if the input has an audio track. The example on the right does this. The "include_if_source_has" is an array of the required input tracks. All tracks start with 0 numbering. Therefore audio[0] is the first audio track, video[0] is the first video track, and subtitles[0] is the first subtitle track. If you would like to verify the existence of a particular channel within an audio track, it would be represented like below (this references the 2nd channel of the 1st audio track):
"include_if_source_has": [ "components::audio_0::audio[1]" ]
Example include_if_source_has
{
"name": "Hybrik Include_if_source_has Example",
"payload": {
"elements": [
{
"uid": "source_file",
"kind": "source",
"payload": {
"kind": "asset_url",
"payload": {
"storage_provider": "s3",
"url": "s3://my_bucket/my_input_folder/my_file.mp4"
}
}
},
{
"uid": "transcode_task",
"kind": "transcode",
"payload": {
"location": {
"storage_provider": "s3",
"path": "s3://my_bucket/my_output_folder"
},
"targets": [
{
"file_pattern": "{source_basename}_video.mp4",
"existing_files": "replace",
"container": {
"kind": "mp4"
},
"video": {
"codec": "h264",
"bitrate_mode": "vbr",
"bitrate_kb": 1000,
"max_bitrate_kb": 1150,
"height": 720
}
},
{
"include_if_source_has": [
"audio[0]"
],
"file_pattern": "{source_basename}_audio.mp4",
"existing_files": "replace",
"container": {
"kind": "mp4"
},
"audio": [
{
"channels": 2,
"codec": "aac_lc",
"sample_rate": 48000,
"bitrate_kb": 128
}
]
}
]
}
}
],
"connections": [
{
"from": [
{
"element": "source_file"
}
],
"to": {
"success": [
{
"element": "transcode_task"
}
]
}
}
]
}
}