示例#1
0
# 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 . "\n";
    echo "\nSrc has filename = " . $src->entry->content->params->filename . "\n";
    # launch single encoding job
    $job = $rats->createSingleJob(RATS_FORMAT_MP4_KEEP_SIZE, $src->entry->content->params->filename, "test/rats_single_job/mymovie", "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 single 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) {
        echo "\n\nA META content instance has been created at " . $job->entry->cdn_report->content;
    }
    # if YouTube syncing is enabled for your user account => the ID of the YouTube video can be retrieved from the CDN report
    if ($job->entry->cdn_report->yt_id) {