On this page

Video Metadata

Introduction

Sometimes it's useful to get source video metadata before launching a transcoding task. For example, you may need original width and height or duration values. Video metadata can be used to get information about a specific video, which can be used to categorize your content or adjust parts of your workflow.

How to get video metadata

1
Start a task with "metadata" output

To view the metadata from your video, first start a task with the /v1/start_encode2 method containing a format object with an output that is set to metadata. If you plan to automate this process, it is recommended that you also set the metadata_version so that changes to the data structure in future versions don't affect your workflow.

Example:

{
  "query": {
    "source": "https://nyc3.s3.qencode.com/qencode/bbb_30s.mp4",
    "format": [
      {
        "output": "metadata",
        "metadata_version": "4.1.5"
      }
    ]
  }
}

2
Open the file with metadata

After the job is complete, you will be provided with a URL pointing to a JSON file with the video metadata.

All SDKs we provide allow to do this just with a few lines of code.

Request Example
{
  "query": {
    "source": "https://nyc3.s3.qencode.com/qencode/bbb_30s.mp4",
    "format": [
      {
        "output": "metadata",
        "metadata_version": "4.1.5"
      }
    ]
  }
}
client = qencode.client(API_KEY)
metadata = client.get_metadata(VIDEO_URL)
print('Metadata: ' + metadata)
use Qencode\QencodeApiClient;
use Qencode\Classes\Metadata;

$q = new QencodeApiClient($apiKey);
$video_info = $q->getMetadata($video_url);

list($width, $height) = Metadata::get_video_dimensions($video_info);

$bitrate = Metadata::get_bitrate($video_info);

$framerate = Metadata::get_framerate($video_info);

$duration = Metadata::get_duration($video_info);

Metadata response example is shown below:

{
  "format": {
    "tags": {
      "comment": "Creative Commons Attribution 3.0 - http:\/\/bbb3d.renderfarming.net",
      "compatible_brands": "isomiso2avc1mp41",
      "title": "Big Buck Bunny, Sunflower version",
      "major_brand": "isom",
      "artist": "Blender Foundation 2008, Janus Bager Kristensen 2013",
      "minor_version": "512",
      "composer": "Sacha Goedegebure",
      "genre": "Animation",
      "encoder": "Lavf58.12.100"
    },
    "nb_streams": 2,
    "start_time": "0.000000",
    "format_long_name": "QuickTime \/ MOV",
    "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
    "filename": "https:\/\/nyc3.s3.qencode.com\/qencode\/bbb_30s.mp4",
    "bit_rate": "4655418",
    "nb_programs": 0,
    "duration": "30.017000",
    "probe_score": 100,
    "size": "17467714"
  },
  "streams": [
    {
      "pix_fmt": "yuv420p",
      "sample_aspect_ratio": "1:1",
      "refs": 1,
      "codec_type": "video",
      "coded_height": 1088,
      "bit_rate": "4327727",
      "codec_name": "h264",
      "duration": "30.016667",
      "is_avc": "true",
      "nb_frames": "1801",
      "codec_time_base": "1\/120",
      "index": 0,
      "start_pts": 1980,
      "disposition": {
        "comment": 0,
        "forced": 0,
        "lyrics": 0,
        "default": 1,
        "visual_impaired": 0,
        "dub": 0,
        "karaoke": 0,
        "clean_effects": 0,
        "timed_thumbnails": 0,
        "attached_pic": 0,
        "original": 0,
        "hearing_impaired": 0
      },
      "width": 1920,
      "coded_width": 1920,
      "profile": "High",
      "chroma_location": "left",
      "tags": {
        "handler_name": "VideoHandler",
        "language": "und"
      },
      "r_frame_rate": "60\/1",
      "start_time": "0.033000",
      "time_base": "1\/60000",
      "codec_tag_string": "avc1",
      "duration_ts": 1801000,
      "codec_long_name": "H.264 \/ AVC \/ MPEG-4 AVC \/ MPEG-4 part 10",
      "display_aspect_ratio": "16:9",
      "codec_tag": "0x31637661",
      "height": 1080,
      "avg_frame_rate": "60\/1",
      "level": 42,
      "bits_per_raw_sample": "8",
      "has_b_frames": 2,
      "nal_length_size": "4"
    },
    {
      "side_data_list": [
        {
          "side_data_type": "Audio Service Type"
        }
      ],
      "ltrt_cmixlev": "-1.000000",
      "sample_fmt": "fltp",
      "bits_per_sample": 0,
      "codec_type": "audio",
      "channels": 6,
      "duration": "30.016000",
      "bit_rate": "320000",
      "codec_name": "ac3",
      "loro_cmixlev": "-1.000000",
      "loro_surmixlev": "-1.000000",
      "nb_frames": "938",
      "codec_time_base": "1\/48000",
      "index": 1,
      "start_pts": 0,
      "disposition": {
        "comment": 0,
        "forced": 0,
        "lyrics": 0,
        "default": 1,
        "visual_impaired": 0,
        "dub": 0,
        "karaoke": 0,
        "clean_effects": 0,
        "timed_thumbnails": 0,
        "attached_pic": 0,
        "original": 0,
        "hearing_impaired": 0
      },
      "dmix_mode": "-1",
      "tags": {
        "handler_name": "SoundHandler",
        "language": "und"
      },
      "r_frame_rate": "0\/0",
      "start_time": "0.000000",
      "time_base": "1\/48000",
      "codec_tag_string": "ac-3",
      "duration_ts": 1440768,
      "codec_long_name": "ATSC A\/52A (AC-3)",
      "codec_tag": "0x332d6361",
      "ltrt_surmixlev": "-1.000000",
      "avg_frame_rate": "0\/0",
      "channel_layout": "5.1(side)",
      "sample_rate": "48000"
    }
  ],
  "programs": []
}

Need More Help?

For additional information, tutorials, or support, visit the Qencode Documentation pageLink or contact Qencode Support at support@qencode.com.