Skip to content

Commit

Permalink
### Changed
Browse files Browse the repository at this point in the history
* `hasSettings` -> `hasCpSettings` for Craft 3 beta 8 compatibility
* Added Craft 3 beta 8 compatible settings
* Modified config service calls for Craft 3 beta 8
  • Loading branch information
khalwat committed Mar 25, 2017
1 parent 15b46a9 commit fa4badb
Show file tree
Hide file tree
Showing 10 changed files with 428 additions and 187 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## 1.0.5 - 2017.03.24
### Changed
* `hasSettings` -> `hasCpSettings` for Craft 3 beta 8 compatibility
* Added Craft 3 beta 8 compatible settings
* Modified config service calls for Craft 3 beta 8

## 1.0.4 - 2017.03.12
### Added
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"hasCpSection": false,
"changelogUrl": "https://raw.githubusercontent.com/nystudio107/craft3-transcoder/master/CHANGELOG.md",
"components": {
"transcoder": "nystudio107\\transcoder\\services\\Transcoder"
"transcode": "nystudio107\\transcoder\\services\\Transcode"
},
"class": "nystudio107\\transcoder\\Transcoder"
}
Expand Down
33 changes: 26 additions & 7 deletions src/Transcoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@

namespace nystudio107\transcoder;

use nystudio107\transcoder\services\Transcoder as TranscoderService;
use nystudio107\transcoder\services\Transcode;
use nystudio107\transcoder\variables\TranscoderVariable;
use nystudio107\transcoder\models\Settings;

use Craft;
use craft\base\Plugin;
Expand All @@ -22,13 +23,13 @@
use yii\base\Event;

/**
* Class Transcoder
* Class Transcode
*
* @author nystudio107
* @package Transcoder
* @package Transcode
* @since 1.0.0
*
* @property TranscoderService transcoder
* @property Transcode $transcode
*/
class Transcoder extends Plugin
{
Expand Down Expand Up @@ -56,20 +57,27 @@ public function init()
$this->controllerNamespace = 'nystudio107\transcoder\console\controllers';
}

// Add the Transcoder path to the list of things the Clear Caches tool can delete.
// Add the Transcode path to the list of things the Clear Caches tool can delete.
Event::on(
ClearCaches::className(),
ClearCaches::EVENT_REGISTER_CACHE_OPTIONS,
function (RegisterCacheOptionsEvent $event) {
$event->options[] = [
'key' => 'transcoder',
'label' => Craft::t('transcoder', 'Transcoder caches'),
'action' => Craft::$app->config->get('transcoderPath', 'transcoder')
'action' => Transcoder::$plugin->getSettings()->transcoderPath,
];
}
);

Craft::info('Transcoder ' . Craft::t('transcoder', 'plugin loaded'), __METHOD__);
Craft::info(
Craft::t(
'transcoder',
'{name} plugin loaded',
['name' => $this->name]
),
__METHOD__
);
}

/**
Expand All @@ -79,4 +87,15 @@ public function defineTemplateComponent()
{
return TranscoderVariable::class;
}

// Protected Methods
// =========================================================================

/**
* @inheritdoc
*/
protected function createSettingsModel()
{
return new Settings();
}
}
135 changes: 67 additions & 68 deletions src/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
/**
* Transcoder config.php
*
* Completely optional configuration settings for Transcoder if you want to
* customize some of its more esoteric behavior, or just want specific control
* over things.
* This file exists only as a template for the Transcoder settings.
* It does nothing on its own.
*
* Don't edit this file, instead copy it to 'craft/config' as 'transcoder.php'
* and make your changes there.
* and make your changes there to override default settings.
*
* Once copied to 'craft/config', this file will be multi-environment aware as
* well, so you can have different settings groups for each environment, just as
Expand All @@ -26,103 +25,103 @@
return [

// The path to the ffmpeg binary
"ffmpegPath" => "/usr/bin/ffmpeg",
'ffmpegPath' => '/usr/bin/ffmpeg',

// The path to the ffprobe binary
"ffprobePath" => "/usr/bin/ffprobe",
'ffprobePath' => '/usr/bin/ffprobe',

// The options to use for ffprobe
"ffprobeOptions" => "-v quiet -print_format json -show_format -show_streams",
'ffprobeOptions' => '-v quiet -print_format json -show_format -show_streams',

// The path where the transcoded videos are stored; must have a trailing /
"transcoderPath" => $_SERVER['DOCUMENT_ROOT'] . "/transcoder/",
'transcoderPath' => '{DOCUMENT_ROOT}/transcoder/',

// The URL where the transcoded videos are stored; must have a trailing /
"transcoderUrl" => "/transcoder/",
'transcoderUrl' => '/transcoder/',

// Use a md5 hash for the filenames instead of parameterized naming
"useHashedNames" => false,
'useHashedNames' => false,

// Preset video encoders
"videoEncoders" => [
"h264" => [
"fileSuffix" => ".mp4",
"fileFormat" => "mp4",
"videoCodec" => "libx264",
"videoCodecOptions" => "-vprofile high -preset slow -crf 22",
"audioCodec" => "libfdk_aac",
"audioCodecOptions" => "-async 1000",
'videoEncoders' => [
'h264' => [
'fileSuffix' => '.mp4',
'fileFormat' => 'mp4',
'videoCodec' => 'libx264',
'videoCodecOptions' => '-vprofile high -preset slow -crf 22',
'audioCodec' => 'libfdk_aac',
'audioCodecOptions' => '-async 1000',
],
"webm" => [
"fileSuffix" => ".webm",
"fileFormat" => "webm",
"videoCodec" => "libvpx",
"videoCodecOptions" => "-quality good -cpu-used 0",
"audioCodec" => "libvorbis",
"audioCodecOptions" => "-async 1000",
'webm' => [
'fileSuffix' => '.webm',
'fileFormat' => 'webm',
'videoCodec' => 'libvpx',
'videoCodecOptions' => '-quality good -cpu-used 0',
'audioCodec' => 'libvorbis',
'audioCodecOptions' => '-async 1000',
],
],

// Preset audio encoders
"audioEncoders" => [
"mp3" => [
"fileSuffix" => ".mp3",
"fileFormat" => "mp3",
"audioCodec" => "libmp3lame",
"audioCodecOptions" => "",
'audioEncoders' => [
'mp3' => [
'fileSuffix' => '.mp3',
'fileFormat' => 'mp3',
'audioCodec' => 'libmp3lame',
'audioCodecOptions' => '',
],
"aac" => [
"fileSuffix" => ".m4a",
"fileFormat" => "aac",
"audioCodec" => "libfdk_aac",
"audioCodecOptions" => "",
'aac' => [
'fileSuffix' => '.m4a',
'fileFormat' => 'aac',
'audioCodec' => 'libfdk_aac',
'audioCodecOptions' => '',

],
"ogg" => [
"fileSuffix" => ".ogg",
"fileFormat" => "ogg",
"audioCodec" => "libvorbis",
"audioCodecOptions" => "",
'ogg' => [
'fileSuffix' => '.ogg',
'fileFormat' => 'ogg',
'audioCodec' => 'libvorbis',
'audioCodecOptions' => '',
],
],

// Default options for encoded videos
"defaultVideoOptions" => [
'defaultVideoOptions' => [
// Video settings
"videoEncoder" => "h264",
"videoBitRate" => "800k",
"videoFrameRate" => 15,
'videoEncoder' => 'h264',
'videoBitRate' => '800k',
'videoFrameRate' => 15,
// Audio settings
"audioBitRate" => "",
"audioSampleRate" => "",
"audioChannels" => "",
'audioBitRate' => '',
'audioSampleRate' => '',
'audioChannels' => '',
// Spatial settings
"width" => "",
"height" => "",
"sharpen" => true,
// Can be "none", "crop", or "letterbox"
"aspectRatio" => "letterbox",
"letterboxColor" => "",
'width' => '',
'height' => '',
'sharpen' => true,
// Can be 'none', 'crop', or 'letterbox'
'aspectRatio' => 'letterbox',
'letterboxColor' => '',
],

// Default options for video thumbnails
"defaultThumbnailOptions" => [
"fileSuffix" => ".jpg",
"timeInSecs" => 10,
"width" => "",
"height" => "",
"sharpen" => true,
// Can be "none", "crop", or "letterbox"
"aspectRatio" => "letterbox",
"letterboxColor" => "",
'defaultThumbnailOptions' => [
'fileSuffix' => '.jpg',
'timeInSecs' => 10,
'width' => '',
'height' => '',
'sharpen' => true,
// Can be 'none', 'crop', or 'letterbox'
'aspectRatio' => 'letterbox',
'letterboxColor' => '',
],

// Default options for encoded videos
"defaultAudioOptions" => [
"audioEncoder" => "mp3",
"audioBitRate" => "128k",
"audioSampleRate" => "44100",
"audioChannels" => "2",
'defaultAudioOptions' => [
'audioEncoder' => 'mp3',
'audioBitRate' => '128k',
'audioSampleRate' => '44100',
'audioChannels' => '2',
],

];
10 changes: 5 additions & 5 deletions src/console/controllers/DefaultController.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
/**
* Transcoder plugin for Craft CMS 3.x
* Transcode plugin for Craft CMS 3.x
*
* Transcoder
* Transcode
*
* @link https://nystudio107.com
* @copyright Copyright (c) 2017 Transcoder
* @copyright Copyright (c) 2017 Transcode
*/

namespace nystudio107\transcoder\console\controllers;
Expand All @@ -19,8 +19,8 @@
/**
* Default Command
*
* @author Transcoder
* @package Transcoder
* @author Transcode
* @package Transcode
* @since 1.0.0
*/
class DefaultController extends Controller
Expand Down
10 changes: 5 additions & 5 deletions src/controllers/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

/**
* @author nystudio107
* @package Transcoder
* @package Transcode
* @since 1.0.0
*/
class DefaultController extends Controller
Expand All @@ -34,7 +34,7 @@ class DefaultController extends Controller
*/
protected $allowAnonymous = [
'download-file',
'progress'
'progress',
];

// Public Methods
Expand All @@ -49,7 +49,7 @@ class DefaultController extends Controller
public function actionDownloadFile($url)
{
$filePath = parse_url($url, PHP_URL_PATH);
$filePath = $_SERVER['DOCUMENT_ROOT'].$filePath;
$filePath = $_SERVER['DOCUMENT_ROOT'] . $filePath;
Craft::$app->getResponse()->sendFile(
$filePath,
null,
Expand All @@ -73,7 +73,7 @@ public function actionDownloadFile($url)
public function actionProgress($filename)
{
$result = [];
$progressFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$filename.".progress";
$progressFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $filename . ".progress";
if (file_exists($progressFile)) {
$content = @file_get_contents($progressFile);
if ($content) {
Expand Down Expand Up @@ -117,7 +117,7 @@ public function actionProgress($filename)
$result = [
'filename' => $filename,
'duration' => $duration,
'time' => $time,
'time' => $time,
'progress' => $progress,
];
}
Expand Down
Loading

0 comments on commit fa4badb

Please sign in to comment.