Video file video_info key is null

Hello, I am working with video uploads and video processing for the first time on Uploadcare. Pretty slick. I have a question about the response data on fileInfo for a video file. My file’s video_info key is null. I had hoped to find the video’s width and height similar to an image file with image_info. Ultimately I’d like to store the aspect ratio for responsive usage on the frontend.

Can I expect width/height data in that key or is there are reason it is null?

{
    "is_stored": true,
    "done": 32418928,
    "file_id": "61a7e57a-13b9-424a-a419-e3134378831a",
    "total": 32418928,
    "size": 32418928,
    "uuid": "61a7e57a-13b9-424a-a419-e3134378831a",
    "is_image": false,
    "filename": "test.mp4",
    "video_info": null,
    "is_ready": true,
    "original_filename": "test.mp4",
    "image_info": null,
    "mime_type": "video/mp4"
}

Thanks!

Hi @owenhoskins

Thanks for the question!

By default, video_info is always null for uploaded videos. This key has information only for files generated as the output of video processing. This is how the video information object looks like

 "video_info": {
        "duration": 4458,
        "bitrate": 105,
        "audio": {
            "channels": "1",
            "sample_rate": 48000,
            "codec": "aac",
            "bitrate": 43
        },
        "video": {
            "width": 200,
            "codec": "h264",
            "bitrate": 62,
            "frame_rate": 16.67,
            "height": 200
        },
        "format": "mpeg4"
    }

UUID of the output video file can be found in the response from the video API when you post a conversion job

image

Hope that helps.

Hey Alex, that makes sense, thanks for the explanation. Once the file is processed I can pass that new UUID to the Upload API’s /info/ endpoint to get an object with the video_info key I was looking for.

However, I am also using the Javascript API’s fileFrom and accessing a processed video file with it’s cdn url returns an object without the video_info key. In contrast, fileFrom returns the originalImageInfo key when the file is an image.

I noticed that the Upload API’s /info/ endpoint returns an image_info key and not originalImageInfo. Is this related to why that video_info key is not included when using the Javascript API’s fileFrom?

Since I am working with the Uploadcare Widget simply getting that video_info via those methods would be ideal. Would this be possible or should I explore other API options?

On that theme I have one further question: if I have the original UUID but not the processed UUID or visa versa, is it possible using REST API routines to find a reference from one to the other?

Thanks again.

best,
O

There are two endpoints that return file information:

Responses from these endpoints are different. Video information is included in the response from REST API only. The widget is a client of the upload API, so there’s no way to get video info using the JS API of the widget as it requests information from the Upload API. You will need to implement requesting file info from the REST API in order to obtain video information.

The response from the REST API also includes the variations key that contains references to files generated by video processing (if the original file has been processed with video API). Below is an example of the response:

{
    "datetime_removed": null,
    "datetime_stored": "2020-01-03T12:45:20.156548Z",
    "datetime_uploaded": "2020-01-03T12:45:19.977380Z",
    "image_info": null,
    "is_image": false,
    "is_ready": true,
    "mime_type": "video/x-matroska",
    "original_file_url": "https://ucarecdn.com/c7fce2e3-6d5e-4358-9369-33954d6fa854/record.mkv",
    "original_filename": "record.mkv",
    "size": 941655,
    "url": "https://api.uploadcare.com/files/c7fce2e3-6d5e-4358-9369-33954d6fa854/",
    "uuid": "c7fce2e3-6d5e-4358-9369-33954d6fa854",
    "variations": {
        "video/-/format/mp4/-/quality/normal/-/size/200x200/scale_crop/": "65f3b7ac-d146-4c1e-96cc-4988881ab726",
        "video/-/format/mp4/-/quality/normal/-/size/200x200/scale_crop/-/thumbs~1/0/": "1f1323ed-e320-409b-9cdc-951bfd047641"
    },
    "video_info": null
}

Hope that makes sense.

Hey Alex, thanks for another thorough response. I’ve run some tests and here are results:


Variations key via REST API

Passing the UUID of an original file that has been processed with the video API but the response doesn’t seem to contain the variations key:

https://api.uploadcare.com/files/8ea55942-8437-417b-b594-9988842670de/

{
  "datetime_removed": null,
  "datetime_stored": "2020-02-05T17:14:32.411554Z",
  "datetime_uploaded": "2020-02-05T17:14:32.253949Z",
  "image_info": null,
  "is_image": false,
  "is_ready": true,
  "mime_type": "video/quicktime",
  "original_file_url": "https://ucarecdn.com/8ea55942-8437-417b-b594-9988842670de/divbox1.mov",
  "original_filename": "div-box (1).mov",
  "size": 601914,
  "url": "https://api.uploadcare.com/files/8ea55942-8437-417b-b594-9988842670de/",
  "uuid": "8ea55942-8437-417b-b594-9988842670de",
  "source": null
}

video_info via REST API

The REST API doesn’t seem to return the video_info key of a processed file: https://api.uploadcare.com/files/8e8cf6b2-2bdd-434c-aef8-fac328280c7b/

{
    "datetime_removed": null,
    "datetime_stored": "2020-02-05T17:14:43.957407Z",
    "datetime_uploaded": "2020-02-05T17:14:33.085303Z",
    "image_info": null,
    "is_image": false,
    "is_ready": true,
    "mime_type": "video/mp4",
    "original_file_url": "https://ucarecdn.com/8e8cf6b2-2bdd-434c-aef8-fac328280c7b/video.mp4",
    "original_filename": "video.mp4",
    "size": 181412,
    "url": "https://api.uploadcare.com/files/8e8cf6b2-2bdd-434c-aef8-fac328280c7b/",
    "uuid": "8e8cf6b2-2bdd-434c-aef8-fac328280c7b",
    "source": null
}

video_info via Upload API

Where as passing the UUID of the processed video to the UPLOAD API does: https://upload.uploadcare.com/info/?pub_key=1d4eaa7670d5df023abd&file_id=8e8cf6b2-2bdd-434c-aef8-fac328280c7b

{
    "is_stored": true,
    "done": 181412,
    "file_id": "8e8cf6b2-2bdd-434c-aef8-fac328280c7b",
    "total": 181412,
    "size": 181412,
    "uuid": "8e8cf6b2-2bdd-434c-aef8-fac328280c7b",
    "is_image": false,
    "filename": "video.mp4",
    "video_info": {
        "duration": 6417,
        "bitrate": 223,
        "audio": {
            "channels": null,
            "sample_rate": null,
            "codec": null,
            "bitrate": null
        },
        "video": {
            "width": 1000,
            "codec": "h264",
            "bitrate": 223,
            "frame_rate": 60,
            "height": 568
        },
        "format": "mpeg4"
    },
    "is_ready": true,
    "original_filename": "video.mp4",
    "image_info": null,
    "mime_type": "video/mp4"
}

I hope I haven’t simply mixed things up, but I am not getting the results I’d expect based on the info provided! Thanks again.

Hi @owenhoskins,

The variations key is added to the response in REST API v0.6 only. Add the following header to your request:

Accept: application/vnd.uploadcare-v0.6+json

Sorry I should have mentioned this previously.

1 Like

Thanks Alex! Now using the REST API v0.6 both the video_info key and variations keys are included in their respective responses.

1 Like