Skip to content

Commit

Permalink
[1.0] Introducing the "Simple Usage" API (#14)
Browse files Browse the repository at this point in the history
* wip

* wip

* wip

* wip

* Update CHANGELOG.md
  • Loading branch information
chrisbbreuer authored Mar 16, 2021
1 parent 49af41f commit 041b68f
Show file tree
Hide file tree
Showing 10 changed files with 406 additions and 200 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/test.yml → .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
name: Test
name: Run Tests

on: [push]
on:
push:
pull_request:

jobs:
test:
run-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [7.3, 7.4, 8.0]
php: [7.4, 8.0]
laravel: [7.*, 8.*]
dependency-version: [prefer-lowest, prefer-stable]
dependency-version: [prefer-stable]
# dependency-version: [prefer-lowest, prefer-stable]
include:
- laravel: 8.*
testbench: 6.*
Expand All @@ -21,20 +24,13 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v1
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, intl, pdo, pdo_sqlite, sqlite, curl
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: 'us-east-1'
AWS_MEDIACONVERT_ACCOUNT_URL: ${{ secrets.AWS_MEDIACONVERT_ACCOUNT_URL }}
AWS_IAM_ARN: ${{ secrets.AWS_IAM_ARN }}
AWS_QUEUE_ARN: ${{ secrets.AWS_QUEUE_ARN }}

- name: Cache dependencies
uses: actions/cache@v1
Expand All @@ -44,11 +40,15 @@ jobs:

- name: Install dependencies
run: |
composer require "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
- name: Create .env file
run: touch .env # this can be an empty file, just need the test to pass. GitHub Actions uses GitHub Secrets

- name: Execute tests
run: vendor/bin/pest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: 'us-east-1'
AWS_MEDIACONVERT_ACCOUNT_URL: ${{ secrets.AWS_MEDIACONVERT_ACCOUNT_URL }}
AWS_IAM_ARN: ${{ secrets.AWS_IAM_ARN }}
AWS_QUEUE_ARN: ${{ secrets.AWS_QUEUE_ARN }}
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

All notable changes to `laravel-media-converter` will be documented in this file.

## 1.0.0 - 202X-XX-XX
## 1.0.0 - 2021-03-15

- initial release
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@ This is a wrapper package for AWS MediaConvert. Additional drivers may be added.
use Meema\MediaConverter\Facades\MediaConvert;
use Meema\MediaConverter\Jobs\CreateVideoConversion;

// run any of the following MediaConvert methods:
# simple usage
MediaConvert::path('video.mkv') // the s3 path to the file inside the bucket defined in your config (filesystems.disks.s3.bucket)
->optimizeForWeb() // will generate an optmized MP4 for you
->withThumbnails(int $framerateNumerator, int $framerateDenominator, int $maxCaptures, $width = null, $nameModifier = null, $imageQuality = 80) // will generate thumbnails from the video for you, e.g. poster images
->saveTo('my-optimized-video.mp4'); // output file name
->createJob();

# advanced usage
$result = MediaConvert::cancelJob(string $id);
$result = MediaConvert::createJob(array $settings, array $metaData = [], int $priority = 0);
$result = MediaConvert::getJob(string $id);
$result = MediaConvert::listJobs(array $options);

// you may also dispatch a job to convert a video
# you may also dispatch a job to convert a video
dispatch(new CreateVideoConversion($jobSettings, $mediaId)); // $mediaId is optional & refers to the relating model's id
```

Expand Down
172 changes: 1 addition & 171 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,175 +65,5 @@
*/
'statuses_to_track' => ['complete', 'error', 'new_warning', 'progressing', 'status_update', 'input_information', 'queue_hop'],

'settings' => [
'OutputGroups' => [
// thumbnail generation
[
'CustomName' => 'Thumbnails',
'Name' => 'File Group',
'Outputs' => [
[
'ContainerSettings' => [
'Container' => 'RAW',
],
'VideoDescription' => [
'ScalingBehavior' => 'DEFAULT',
'TimecodeInsertion' => 'DISABLED',
'AntiAlias' => 'ENABLED',
'Sharpness' => 50,
'CodecSettings' => [
'Codec' => 'FRAME_CAPTURE',
'FrameCaptureSettings' => [
'FramerateNumerator' => null, // to be set dynamically
'FramerateDenominator' => null, // to be set dynamically
'MaxCaptures' => null, // to be set dynamically
'Quality' => 80,
],
],
'AfdSignaling' => 'NONE',
'DropFrameTimecode' => 'ENABLED',
'RespondToAfd' => 'NONE',
'ColorMetadata' => 'INSERT',
'Width' => null, // to be set dynamically
],
'NameModifier' => '.$w$x$h$', // e.g. moderation-test-video.240x136.0000098.jpg
],
],
'OutputGroupSettings' => [
'Type' => 'FILE_GROUP_SETTINGS',
'FileGroupSettings' => [
'Destination' => null, // to be set dynamically
'DestinationSettings' => [
'S3Settings' => [
'AccessControl' => [
'CannedAcl' => 'PUBLIC_READ',
],
],
],
],
],
],

// optimize-mp4 output setting
[
'CustomName' => 'MP4',
'Name' => 'File Group',
'Outputs' => [
[
'ContainerSettings' => [
'Container' => 'MP4',
'Mp4Settings' => [
'CslgAtom' => 'INCLUDE',
'FreeSpaceBox' => 'EXCLUDE',
'MoovPlacement' => 'PROGRESSIVE_DOWNLOAD',
],
],
'VideoDescription' => [
'ScalingBehavior' => 'DEFAULT',
'TimecodeInsertion' => 'DISABLED',
'AntiAlias' => 'ENABLED',
'Sharpness' => 50,
'CodecSettings' => [
'Codec' => 'H_264',
'H264Settings' => [
'InterlaceMode' => 'PROGRESSIVE',
'NumberReferenceFrames' => 3,
'Syntax' => 'DEFAULT',
'Softness' => 0,
'GopClosedCadence' => 1,
'GopSize' => 90,
'Slices' => 1,
'GopBReference' => 'DISABLED',
'MaxBitrate' => 8000000,
'SlowPal' => 'DISABLED',
'SpatialAdaptiveQuantization' => 'ENABLED',
'TemporalAdaptiveQuantization' => 'ENABLED',
'FlickerAdaptiveQuantization' => 'DISABLED',
'EntropyEncoding' => 'CABAC',
'FramerateControl' => 'INITIALIZE_FROM_SOURCE',
'RateControlMode' => 'QVBR',
'QvbrSettings' => [
'QvbrQualityLevel' => 7,
'QvbrQualityLevelFineTune' => 0,
],
'CodecProfile' => 'MAIN',
'Telecine' => 'NONE',
'MinIInterval' => 0,
'AdaptiveQuantization' => 'HIGH',
'CodecLevel' => 'AUTO',
'FieldEncoding' => 'PAFF',
'SceneChangeDetect' => 'ENABLED',
'QualityTuningLevel' => 'SINGLE_PASS',
'FramerateConversionAlgorithm' => 'DUPLICATE_DROP',
'UnregisteredSeiTimecode' => 'DISABLED',
'GopSizeUnits' => 'FRAMES',
'ParControl' => 'INITIALIZE_FROM_SOURCE',
'NumberBFramesBetweenReferenceFrames' => 2,
'RepeatPps' => 'DISABLED',
],
],
'AfdSignaling' => 'NONE',
'DropFrameTimecode' => 'ENABLED',
'RespondToAfd' => 'NONE',
'ColorMetadata' => 'INSERT',
],
'AudioDescriptions' => [
[
'AudioTypeControl' => 'FOLLOW_INPUT',
'CodecSettings' => [
'Codec' => 'AAC',
'AacSettings' => [
'AudioDescriptionBroadcasterMix' => 'NORMAL',
'Bitrate' => 96000,
'RateControlMode' => 'CBR',
'CodecProfile' => 'LC',
'CodingMode' => 'CODING_MODE_2_0',
'RawFormat' => 'NONE',
'SampleRate' => 48000,
'Specification' => 'MPEG4',
],
],
'LanguageCodeControl' => 'FOLLOW_INPUT',
],
],
],
],
'OutputGroupSettings' => [
'Type' => 'FILE_GROUP_SETTINGS',
'FileGroupSettings' => [
'Destination' => null, // to be set dynamically
'DestinationSettings' => [
'S3Settings' => [
'AccessControl' => [
'CannedAcl' => 'PUBLIC_READ',
],
],
],
],
],
],
],
'AdAvailOffset' => 0,
'Inputs' => [
[
'AudioSelectors' => [
'Audio Selector 1' => [
'Offset' => 0,
'DefaultSelection' => 'DEFAULT',
'ProgramSelection' => 1,
],
],
'VideoSelector' => [
'ColorSpace' => 'FOLLOW',
],
'FilterEnable' => 'AUTO',
'PsiControl' => 'USE_PSI',
'FilterStrength' => 0,
'DeblockFilter' => 'DISABLED',
'DenoiseFilter' => 'DISABLED',
'TimecodeSource' => 'EMBEDDED',
'FileInput' => null, // to be set dynamically
],
],
],
'job_settings' => \Meema\MediaConverter\Helpers\DefaultMediaConvertJobSettings::class,
];
38 changes: 38 additions & 0 deletions src/Contracts/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,44 @@

interface Converter
{
/**
* Sets the path of the file input.
*
* @param string $path
* @param string|null $bucket
* @return \Meema\MediaConverter\Converters\MediaConvert
*/
public function path(string $path, $bucket = null);

/**
* Generates a web optimized MP4.
*
* @return \Meema\MediaConverter\Converters\MediaConvert
*/
public function optimizeForWeb();

/**
* Sets the settings required to generate the proper amount of thumbnails.
*
* @param int $framerateNumerator
* @param int $framerateDenominator
* @param int $maxCaptures
* @param int|null $width
* @param string|null $nameModifier
* @param int $imageQuality
* @return \Meema\MediaConverter\Converters\MediaConvert
*/
public function withThumbnails(int $framerateNumerator, int $framerateDenominator, int $maxCaptures, $width = null, $nameModifier = null, $imageQuality = 80);

/**
* Sets the path & executes the job.
*
* @param string $s3Path
* @param string|null $s3bucket
* @return \Aws\Result
*/
public function saveTo(string $s3Path, $s3bucket = null);

/**
* Cancels an active job.
*
Expand Down
Loading

0 comments on commit 041b68f

Please sign in to comment.