PHP code example of clearcut / clearcut-laravel

1. Go to this page and download the library: Download clearcut/clearcut-laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

clearcut / clearcut-laravel example snippets


   Route::group(['middleware' => ['jwt.verify', 'admin']], function () {
       // ...the panel's own routes...

       

   Route::prefix('recordings')->group(function () {
   

use Clearcut\Video\ClearcutClient;
use Clearcut\Video\Data\JobRequest;

public function __construct(private ClearcutClient $clearcut) {}

$status = $this->clearcut->process(new JobRequest(
    videoId: (string) $recording->id,
    sourceKey: $recording->storage_key,   // a bucket key, not a URL
    mode: JobRequest::MODE_AUTO,
    brand: 'acme',
));

// Minutes, so poll rather than wait.
$status = $this->clearcut->job($status->jobId);
$status->finished();   // done | failed | cancelled

use Clearcut\Video\Data\BatchRequest;

$batch = $this->clearcut->processBatch(BatchRequest::of(
    ['12' => 'media/originals/12/source.mp4',
     '13' => 'media/originals/13/source.mp4'],
    new JobRequest(
        videoId: 'unused-by-the-batch',   // each recording carries its own
        sourceKey: 'unused-by-the-batch',
        mode: JobRequest::MODE_AUTO,
        brand: 'acme',
    ),
));

$batch = $this->clearcut->batch($batch->batchId);   // the whole batch, one request
$batch->progress;      // 0..1, weighted by each recording's length
$batch->failures();    // the recordings that need redoing
$batch->successes();   // keep these — they are finished encodes

$analysis = $this->clearcut->analyze($request);      // detect only
$proposal = $this->clearcut->proposal($analysis->jobId);

$this->clearcut->decide($analysis->jobId, ['pan-0' => 'kept']);

// Correct a box, or draw one detection missed. Both return the region as saved.
$this->clearcut->editRegion($analysis->jobId, 'pan-0', ['w' => 240, 't1' => 12.5]);
$this->clearcut->addRegion($analysis->jobId, x: 40, y: 300, w: 200, h: 36, t0: 4.0, t1: 9.0);

$encode = $this->clearcut->apply($analysis->jobId, brand: 'acme');

$this->clearcut->brands();     // what this deployment can watermark with
$this->clearcut->profiles();   // speed against thoroughness
$this->clearcut->health();     // reachable? which binaries resolved?

app(Clearcut\Video\BrandLabels::class)->labelFor('acme');   // 'Acme', or 'acme' when unknown
app(Clearcut\Video\BrandLabels::class)->has('acme');
powershell
composer 
bash
php artisan tinker --execute="dump(app(Clearcut\Video\ClearcutClient::class)->health());"
php artisan tinker --execute="dump(app(Clearcut\Video\ClearcutClient::class)->brands());"
bash
php artisan clearcut:process --video=12 --video=13 --mode=auto --mark=logo --brand=acme --wait
php artisan clearcut:process --video=12 --review          # detect; review in the panel
php artisan clearcut:sync                                 # settle what a stopped worker left open
php artisan clearcut:sync --minutes=30 --clean-temp       # worth scheduling
bash
php artisan vendor:publish --tag=clearcut-migrations