Skip to main content

Sample JSON

Introduction

Hybrik uses JSON to describe Jobs. These examples show different types of jobs, including both simple and complex workflows.

Download all of the sample JSON files here:
Sample JSON files

Basic Transcode

This example JSON shows how to transcode a single source file and put the result in a specified target location. The transcode parameters are set in the "targets" array and specify that the resulting video will have the following characteristics:

  • container: mp4
  • video codec: h.264
  • height: 640 pixels
  • width: 360 pixels
  • framerate: 23.976 frames/sec
  • video bitrate: 600kbps
  • audio codec: HEAAC V2
  • sample rate: 44.1kHz
  • audio bitrate: 128kbps

Example transcode

{
"name": "Hybrik API Example#1 - simple transcode",
"payload": {
"elements": [
{
"uid": "source_file",
"kind": "source",
"payload": {
"kind": "asset_url",
"payload": {
"storage_provider": "s3",
"url": "s3://hybrik-examples/public/sources/sample1.mp4"
}
}
},
{
"uid": "transcode_task",
"kind": "transcode",
"payload": {
"location": {
"storage_provider": "s3",
"path": "s3://hybrik-examples/public/output/example1"
},
"targets": [
{
"file_pattern": "%s.mp4",
"existing_files": "replace",
"container": {
"kind": "mp4"
},
"video": {
"codec": "h264",
"width": 640,
"height": 360,
"frame_rate": 23.976,
"bitrate_kb": 600
},
"audio": [
{
"codec": "heaac_v2",
"channels": 2,
"sample_rate": 44100,
"bitrate_kb": 128
}
]
}
]
}
}
],
"connections": [
{
"from": [
{
"element": "source_file"
}
],
"to": {
"success": [
{
"element": "transcode_task"
}
]
}
}
]
}
}

Transcode - FFMPEG Arguments

This example JSON shows how to transcode a single source file and put the result in a specified target location, but in this case it uses ffmpeg command line arguments to define the transcode parameters. Some customers are already using ffmpeg in their workflow and therefore can use their ffmpeg settings directly in Hybrik.

  • container: mp4
  • video codec: h.264
  • height: 640 pixels
  • width: 360 pixels
  • constant rate factor: 22
  • framerate: 23.976 frames/sec
  • video bitrate: 800kbps
  • audio codec: AAC
  • sample rate: 44.1kHz
  • audio bitrate: 128kbps

Example ffmpeg

{
"name": "Hybrik API Example#2 - simple transcode, ffmpeg",
"payload": {
"elements": [
{
"uid": "source_file",
"kind": "source",
"payload": {
"kind": "asset_url",
"payload": {
"storage_provider": "s3",
"url": "s3://hybrik-examples/public/sources/sample1.mp4"
}
}
},
{
"uid": "transcode_task",
"kind": "transcode",
"payload": {
"location": {
"storage_provider": "s3",
"path": "s3://hybrik-examples/public/output/copy/example2"
},
"targets": [
{
"file_pattern": "{source_basename}.mp4",
"existing_files": "replace",
"ffmpeg_args": "-pix_fmt yuv420p -c:v libx264 -crf 22 -preset medium -s 640x360 -b:v 800k -acodec libfdk_aac -ar 44100 -ac 2 -b:a 128k -f mp4"
}
]
}
}
],
"connections": [
{
"from": [
{
"element": "source_file"
}
],
"to": {
"success": [
{
"element": "transcode_task"
}
]
}
}
]
}
}

Transcode->Copy->Notify

This example JSON shows how to make a more complex workflow. The job specifies that the source file will be transcoded to one location, copied to a second location, and then notify someone via email upon completion of the copy. Both success and failure notifications are specified.


Example transcode-copy-notify

{
"name": "Hybrik API Example#3 - transcode, copy and notify",
"payload": {
"elements": [
{
"uid": "source_file",
"kind": "source",
"payload": {
"kind": "asset_url",
"payload": {
"storage_provider": "s3",
"url": "s3://hybrik-examples/public/sources/sample1.mp4"
}
}
},
{
"uid": "transcode_task",
"kind": "transcode",
"payload": {
"location": {
"storage_provider": "s3",
"path": "s3://hybrik-examples/public/output/transcode/example3"
},
"targets": [
{
"file_pattern": "{source_basename}.mp4",
"existing_files": "replace",
"container": {
"kind": "mp4"
},
"video": {
"codec": "h264",
"width": 640,
"height": 360,
"frame_rate": 23.976,
"bitrate_kb": 600
},
"audio": [
{
"codec": "heaac_v2",
"channels": 2,
"sample_rate": 44100,
"bitrate_kb": 128
}
]
}
]
}
},
{
"uid": "copy_task",
"kind": "copy",
"payload": {
"target": {
"location": {
"storage_provider": "s3",
"path": "s3://hybrik-examples/public/output/copy/example3"
},
"existing_files": "replace",
"file_pattern": "{source_name}"
}
}
},
{
"uid": "success_notify",
"kind": "notify",
"task": {
"retry_method": "fail"
},
"payload": {
"notify_method": "email",
"email": {
"recipients": "{account_owner_email}",
"subject": "Example 3 succeeded",
"body": "congratulation, you completed example 3"
}
}
},
{
"uid": "error_notify",
"kind": "notify",
"payload": {
"notify_method": "email",
"email": {
"recipients": "{account_owner_email}",
"subject": "Example 3 failed",
"body": "too bad, example 3 did not complete"
}
}
}
],
"connections": [
{
"from": [
{
"element": "source_file"
}
],
"to": {
"success": [
{
"element": "transcode_task"
}
]
}
},
{
"from": [
{
"element": "transcode_task"
}
],
"to": {
"success": [
{
"element": "copy_task"
}
],
"error": [
{
"element": "error_notify"
}
]
}
},
{
"from": [
{
"element": "copy_task"
}
],
"to": {
"success": [
{
"element": "success_notify"
}
],
"error": [
{
"element": "error_notify"
}
]
}
}
]
}
}

Analyze->QC->Transcode

This example JSON shows how to make a more complex workflow incorporating both Analyze and QC tasks. The job specifies that the source file will first be analyzed for both audio and video properties. Then the QC task will be performed which will verify the following parameters:

  • overall file size greater than 10kb
  • at least one audio channel
  • an audio sample rate greater than 11kHz and less than 96kHz
  • an audio level greater than -60db
  • no periods of silence longer than 5 seconds
  • a video width greater than 320 pixels
  • a video hight greater than 240 pixels
  • no periods of black video longer than 5 seconds

Example analyze-qc-transcode

{
"name": "Hybrik API Example#4 - analyze, qc, transcode",
"payload": {
"elements": [
{
"uid": "source_file",
"kind": "source",
"payload": {
"kind": "asset_url",
"payload": {
"storage_provider": "s3",
"url": "s3://hybrik-public/sample_sources/sample1.mp4"
}
}
},
{
"uid": "analyze_task",
"kind": "analyze",
"payload": {
"general_properties": {
"enabled": true
},
"deep_properties": {
"video": {
"black": {
"enabled": true,
"is_optional": true,
"black_level": 0.03,
"duration_sec": 1
}
},
"audio": {
"levels": {
"enabled": true,
"is_optional": true
},
"silence": {
"enabled": true,
"is_optional": true,
"noise_db": -60,
"duration_sec": 1
}
}
}
}
},
{
"uid": "qc_task",
"kind": "qc",
"payload": {
"conditions": {
"pass": [
{
"condition": "general_properties.container.size_kb > 10000",
"message_pass": "PASS: Source file size is greater than 10 megabytes, size = {general_properties.container.size_kb} kb.",
"message_fail": "FAIL: Source file size is less than or equal to 10 megabytes, size = {general_properties.container.size_kb} kb."
},
{
"condition": "general_properties.video.width >= 1920",
"message_pass": "PASS: Video frame width is greater than or equal to 1920, width is {general_properties.video.width} pixels.",
"message_fail": "FAIL: Video frame width is less than 1920, width is {general_properties.video.width} pixels."
},
{
"condition": "general_properties.video.height >= 1080",
"message_pass": "PASS: Video frame height is greater than or equal to 1080, height is {general_properties.video.height} pixels.",
"message_fail": "FAIL: Video frame height is less than 1080, height is {general_properties.video.height} pixels."
},
{
"condition": "general_properties.audio.size() >= 1",
"message_pass": "PASS: Number of audio tracks is greater than or equal to 1, there are {general_properties.audio.size()} tracks",
"message_fail": "FAIL: There are no audio tracks."
},
{
"condition": "general_properties.audio[0].sample_rate >= 44100",
"message_pass": "PASS: Audio sample rate is greater than or equal to 44.1 kHz, sample rate is {general_properties.audio[0].sample_rate} Hz.",
"message_fail": "FAIL: Audio sample rate is less than 44.1 kHz, sample rate is {general_properties.audio[0].sample_rate} Hz."
},
{
"condition": "deep_properties.video.black.size() == 0 || deep_properties.video.black.max('duration') <= 5",
"message_pass": "PASS: Longest black segment is shorter than 5 seconds.",
"message_fail": "FAIL: At least one black segment is longer than or equal to 5 seconds."
},
{
"condition": "deep_properties.audio[0].levels.rms_level_db >= -60",
"message_pass": "PASS: Audio RMS level is higher than or equal to -60 dB, level is {deep_properties.audio[0].levels.rms_level_db} dB.",
"message_fail": "FAIL: Audio level is lower than -60dB, level is {deep_properties.audio[0].levels.rms_level_db} dB."
},
{
"condition": "deep_properties.audio[0].silence.size() == 0 || deep_properties.audio[0].silence.max('duration') <= 5",
"message_pass": "PASS: Longest audio silence is shorter than 5 seconds.",
"message_fail": "FAIL: At least one audio silence is longer than or equal to 5 seconds."
}
]
}
}
},
{
"uid": "transcode_task",
"kind": "transcode",
"payload": {
"location": {
"storage_provider": "s3",
"path": "s3://hybrik-examples/public/output/transcode/example4"
},
"targets": [
{
"file_pattern": "{source_basename}.mp4",
"existing_files": "replace",
"container": {
"kind": "mp4"
},
"video": {
"codec": "h264",
"width": 640,
"height": 360,
"frame_rate": 23.976,
"bitrate_kb": 600
},
"audio": [
{
"codec": "heaac_v2",
"channels": 2,
"sample_rate": 44100,
"bitrate_kb": 128
}
]
}
]
}
}
],
"connections": [
{
"from": [
{
"element": "source_file"
}
],
"to": {
"success": [
{
"element": "analyze_task"
}
]
}
},
{
"from": [
{
"element": "analyze_task"
}
],
"to": {
"success": [
{
"element": "qc_task"
}
]
}
},
{
"from": [
{
"element": "qc_task"
}
],
"to": {
"success": [
{
"element": "transcode_task"
}
]
}
}
]
}
}

HLS Transcode

This example creates a four-layer HLS file. The parameters of the HLS file are:

  • 4 layers of h.264 video
  • 10 second segment length
  • h.264 video
  • HEAAC V2 audio

Example hls-package

{
"name": "Hybrik Example #5 - HLS encode",
"payload": {
"elements": [
{
"uid": "source_file",
"kind": "source",
"payload": {
"kind": "asset_url",
"payload": {
"storage_provider": "s3",
"url": "s3://hybrik-examples/public/sources/sample1.mp4"
}
}
},
{
"uid": "transcode_task",
"kind": "transcode",
"payload": {
"location": {
"storage_provider": "s3",
"path": "s3://hybrik-examples/public/output/transcode/example5"
},
"manifests": [
{
"file_pattern": "{source_basename}.m3u8",
"kind": "hls",
"uid": "main_hls"
}
],
"options": {
"pipeline": {
"use_agressive_mt": true
}
},
"targets": [
{
"manifest_uids": [
"main_hls"
],
"file_pattern": "{source_basename}_Layer1.m3u8",
"existing_files": "replace",
"container": {
"kind": "hls",
"segment_duration": 10,
"segment_file_pattern": "{target_dir}/{target_basename}_%05d.ts"
},
"video": {
"codec": "h264",
"width": 256,
"height": 144,
"frame_rate": 23.976,
"bitrate_kb": 180
},
"audio": [
{
"codec": "heaac_v2",
"channels": 2,
"sample_rate": 44100,
"bitrate_kb": 64
}
]
},
{
"manifest_uids": [
"main_hls"
],
"file_pattern": "{source_basename}_Layer2.m3u8",
"existing_files": "replace",
"container": {
"kind": "hls",
"segment_duration": 10,
"segment_file_pattern": "{target_dir}/{target_basename}_%05d.ts"
},
"video": {
"codec": "h264",
"width": 512,
"height": 288,
"frame_rate": 23.976,
"bitrate_kb": 640
},
"audio": [
{
"codec": "heaac_v2",
"channels": 2,
"sample_rate": 44100,
"bitrate_kb": 128
}
]
},
{
"manifest_uids": [
"main_hls"
],
"file_pattern": "{source_basename}_Layer3.m3u8",
"existing_files": "replace",
"container": {
"kind": "hls",
"segment_duration": 10,
"segment_file_pattern": "{target_dir}/{target_basename}_%05d.ts"
},
"video": {
"codec": "h264",
"width": 768,
"height": 432,
"frame_rate": 23.976,
"bitrate_kb": 1400
},
"audio": [
{
"codec": "heaac_v2",
"channels": 2,
"sample_rate": 44100,
"bitrate_kb": 192
}
]
},
{
"manifest_uids": [
"main_hls"
],
"file_pattern": "{source_basename}_Layer4.m3u8",
"existing_files": "replace",
"container": {
"kind": "hls",
"segment_duration": 10,
"segment_file_pattern": "{target_dir}/{target_basename}_%05d.ts"
},
"video": {
"codec": "h264",
"width": 1024,
"height": 576,
"frame_rate": 23.976,
"bitrate_kb": 1900
},
"audio": [
{
"codec": "heaac_v2",
"channels": 2,
"sample_rate": 44100,
"bitrate_kb": 192
}
]
}
]
}
}
],
"connections": [
{
"from": [
{
"element": "source_file"
}
],
"to": {
"success": [
{
"element": "transcode_task"
}
]
}
}
]
}
}

MPEG-DASH Transcode

This example creates a 4 layer MPEG-DASH file. The parameters of the MPEG-DASH file are:

  • 4 layers of h.264 video
  • 10 second segment length
  • h.264 video
  • HEAAC V2 audio

Example dash-package

{
"name": "Hybrik Example #6 - DASH encode",
"payload": {
"elements": [
{
"uid": "source_file",
"kind": "source",
"payload": {
"kind": "asset_url",
"payload": {
"storage_provider": "s3",
"url": "s3://hybrik-examples/public/sources/sample1.mp4"
}
}
},
{
"uid": "transcode_task",
"kind": "transcode",
"payload": {
"location": {
"storage_provider": "s3",
"path": "s3://hybrik-examples/public/output/transcode/example6"
},
"manifests": [
{
"file_pattern": "{source_basename}.mpd",
"kind": "dash",
"uid": "main_dash"
}
],
"options": {
"pipeline": {
"use_agressive_mt": true
}
},
"targets": [
{
"manifest_uids": [
"main_dash"
],
"file_pattern": "{source_basename}_Layer1.mpd",
"existing_files": "replace",
"container": {
"kind": "dash-mp4",
"segment_duration": 10
},
"video": {
"codec": "h264",
"width": 256,
"height": 144,
"frame_rate": 23.976,
"bitrate_kb": 180
},
"audio": [
{
"codec": "heaac_v2",
"channels": 2,
"sample_rate": 44100,
"bitrate_kb": 64
}
]
},
{
"manifest_uids": [
"main_dash"
],
"file_pattern": "{source_basename}_Layer2.mpd",
"existing_files": "replace",
"container": {
"kind": "dash-mp4",
"segment_duration": 10
},
"video": {
"codec": "h264",
"width": 512,
"height": 288,
"frame_rate": 23.976,
"bitrate_kb": 640
},
"audio": [
{
"codec": "heaac_v2",
"channels": 2,
"sample_rate": 44100,
"bitrate_kb": 128
}
]
},
{
"manifest_uids": [
"main_dash"
],
"file_pattern": "{source_basename}_Layer3.mpd",
"existing_files": "replace",
"container": {
"kind": "dash-mp4",
"segment_duration": 10
},
"video": {
"codec": "h264",
"width": 768,
"height": 432,
"frame_rate": 23.976,
"bitrate_kb": 1400
},
"audio": [
{
"codec": "heaac_v2",
"channels": 2,
"sample_rate": 44100,
"bitrate_kb": 192
}
]
},
{
"manifest_uids": [
"main_dash"
],
"file_pattern": "{source_basename}_Layer4.mpd",
"existing_files": "replace",
"container": {
"kind": "dash-mp4",
"segment_duration": 10
},
"video": {
"codec": "h264",
"width": 1024,
"height": 576,
"frame_rate": 23.976,
"bitrate_kb": 1900
},
"audio": [
{
"codec": "heaac_v2",
"channels": 2,
"sample_rate": 44100,
"bitrate_kb": 192
}
]
}
]
}
}
],
"connections": [
{
"from": [
{
"element": "source_file"
}
],
"to": {
"success": [
{
"element": "transcode_task"
}
]
}
}
]
}
}