Ejemplo n.º 1
0
# name of your Rambla user account
define('PWD', "xxx");
# password of your Rambla user account
define('LOCAL_PATH', '/path/to/local/video/file');
# add path to local (video) file, to be uploaded to the CDN
require_once 'raws_json/json_client.php';
require_once 'raws_json/rats_service.php';
try {
    $rats = new RatsService(USER, PWD);
    # upload file to RATS
    echo "\nUploading file to RATS, please wait..";
    $src = $rats->createSrc("test_rats_api_src", LOCAL_PATH);
    echo "\nCreated src: " . $src->entry->id;
    echo "\nSrc has filename = " . $src->entry->content->params->filename . "\n";
    # launch batch encoding job
    $job = $rats->createBatchJob(RATS_FORMATGROUP_MP4_JPG_480P, $src->entry->content->params->filename, "test/rats_batch_job/mymovie", "40", "some_client_specific_info", RATS_PROC_EMAIL_TXT . "," . RATS_PROC_EMAIL_JSON);
    # comma-separated list of procs => instruct RATS to send emails when encoding is done
    echo "\nCreated batch job with id: " . $job->entry->id;
    # wait until job has completed
    while (!$rats->isJobComplete($job)) {
        echo "\n.. job not yet complete, sleeping 10 seconds before checking again";
        sleep(10);
        # sleep number of seconds before asking again
    }
    echo "\nJob has completed with status = " . $job->entry->content->params->status;
    # in an asynchronous scenario, you can retrieve the client_passthru from the cdn_report
    if ($job->entry->cdn_report->client_passthru) {
        echo "\n\nThe client_passthru field contains the following string: " . $job->entry->cdn_report->client_passthru;
    }
    # if metadata is enabled for your user account => a META content instance has been created (see https://wiki.rambla.be/META_content_resource)
    if ($job->entry->cdn_report->content) {