phplaravelapibrightcove

How to upload video to Brightcove though API


I am trying to upload a new video to Brightcove though API, at this point I managed to post just json data with information about the video, and everything is appearing fine in Brightcove, but I can't add video file which would be uploaded in Brightcove. I checked other answers, but they are not working for me as they are quite old. Thanks for help!

    $access_token = $this->getAccessToken();
    
    $data = array(
        'name' => 'test',
        'description' => 'test',
        'tags' => ['test']
    );

    $data_string =  json_encode($data);


    $url = 'https://cms.api.brightcove.com/v1/accounts/1774206337/videos';



    $ch = curl_init();


    curl_setopt_array($ch, array(
        CURLOPT_URL  => $url,
        CURLOPT_POSTFIELDS => $data_string,
        CURLOPT_HTTPHEADER     => array(
            'Content-type: application/json',
            "Authorization: Bearer {$access_token}",
        )
    ));

    
    $result = curl_exec($ch);

    dd($result);

Solution

  • You've created a video object, and the JSON body of the response to that call will include the new video's id. You need to make an ingest request for that id.

    If the source file is already accessible at a URL follow https://apis.support.brightcove.com/dynamic-ingest/getting-started/quick-start-dynamic-ingest-api.html and Brightcove will download the file to transcode.

    If you need to upload a file, follow https://apis.support.brightcove.com/dynamic-ingest/getting-started/source-file-upload-api-dynamic-ingest.html