Skip to content

Asset transcoder interface and an implementation using the ZamzarAPI for conversion

License

Notifications You must be signed in to change notification settings

GrovoLearning/grovo-library-asset-transcoder-php

Repository files navigation

grovo-library-asset-transcoder-php

CircleCI codecov

Asset transcoder interface and an implementation using the Zamzar API for conversion.

ZamzarTranscoder

Required environment variables

Input formats supported

The library does not enforce a restriction on input files. An unsupported input file will result in a failed job.

Output formats supported

  • TARGET_FORMAT_PNG
  • TARGET_FORMAT_PDF

This is based on current needs and can be expanded based on needs and what's supported by the transcoding provider.

Construct ZamzarTranscoder

$transcoder = new ZamzarTranscoder(
    getenv('API_KEY'),
    getenv('JOBS_URL'),
    getenv('FILES_URL'),
    getenv('OUTPUT_DIR'),
    true /* sslVerify */
);

Start a conversion job

$jobId = $transcoder->start("source.docx", Transcoder::TARGET_FORMAT_PDF);

Check the status of a job

$status = $transcoder->getStatus($jobId);

$status is an instance of TranscoderJobStatus

TranscoderJobStatus::isWorking() will return true if the job is initializing or still being worked on, and return false if the job has finished (either successfully or unsuccessfully).

TranscoderJobStatus::isSuccessful() will return true if the job was successful, false otherwise.

Finishing the job and getting the output files

$outputFileList = $transcoder->finish($jobId);

$outputFileList will be an array of output files written to disk.

Note: while Zamzar may provide a single zip file for jobs that produce multiple files, the transcoder will unzip the file in these cases and $outputFileList will be the list of list of files within the zip archive.

About

Asset transcoder interface and an implementation using the ZamzarAPI for conversion

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages