1313use craft \base \Model ;
1414
1515/**
16- * Transcode Settings model
16+ * Transcoder Settings model
1717 *
1818 * @author nystudio107
1919 * @package Transcode
2020 * @since 1.0.0
2121 */
2222class Settings extends Model
2323{
24+
25+ // Static Methods
26+ // =========================================================================
27+
28+ /**
29+ * @inheritdoc
30+ */
31+ public function __construct (array $ config = [])
32+ {
33+ // Unset any deprecated properties
34+ if (!empty ($ config )) {
35+ unset($ config ['transcoderPath ' ], $ config ['transcoderUrl ' ]);
36+ }
37+ parent ::__construct ($ config );
38+ }
39+
2440 // Public Properties
2541 // =========================================================================
2642
@@ -51,15 +67,27 @@ class Settings extends Model
5167 *
5268 * @var string
5369 */
54- public $ transcoderPaths = [];
55-
70+ public $ transcoderPaths = [
71+ 'default ' => '@webroot/transcoder/ ' ,
72+ 'video ' => '@webroot/transcoder/video/ ' ,
73+ 'audio ' => '@webroot/transcoder/audio/ ' ,
74+ 'thumbnail ' => '@webroot/transcoder/thumbnail/ ' ,
75+ 'gif ' => '@webroot/transcoder/gif/ ' ,
76+ ];
77+
5678 /**
5779 * The URL where the transcoded videos are stored; must have a trailing /
5880 * Yii2 aliases are supported here
5981 *
6082 * @var string
6183 */
62- public $ transcoderUrls = [];
84+ public $ transcoderUrls = [
85+ 'default ' => '@web/transcoder/ ' ,
86+ 'video ' => '@web/transcoder/video/ ' ,
87+ 'audio ' => '@web/transcoder/audio/ ' ,
88+ 'thumbnail ' => '@web/transcoder/thumbnail/ ' ,
89+ 'gif ' => '@web/transcoder/gif/ ' ,
90+ ];
6391
6492 /**
6593 * Use a md5 hash for the filenames instead of parameterized naming
@@ -75,27 +103,27 @@ class Settings extends Model
75103 */
76104 public $ videoEncoders = [
77105 'h264 ' => [
78- 'fileSuffix ' => '.mp4 ' ,
79- 'fileFormat ' => 'mp4 ' ,
80- 'videoCodec ' => 'libx264 ' ,
106+ 'fileSuffix ' => '.mp4 ' ,
107+ 'fileFormat ' => 'mp4 ' ,
108+ 'videoCodec ' => 'libx264 ' ,
81109 'videoCodecOptions ' => '-vprofile high -preset slow -crf 22 ' ,
82- 'audioCodec ' => 'libfdk_aac ' ,
110+ 'audioCodec ' => 'libfdk_aac ' ,
83111 'audioCodecOptions ' => '-async 1000 ' ,
84112 ],
85113 'webm ' => [
86- 'fileSuffix ' => '.webm ' ,
87- 'fileFormat ' => 'webm ' ,
88- 'videoCodec ' => 'libvpx ' ,
114+ 'fileSuffix ' => '.webm ' ,
115+ 'fileFormat ' => 'webm ' ,
116+ 'videoCodec ' => 'libvpx ' ,
89117 'videoCodecOptions ' => '-quality good -cpu-used 0 ' ,
90- 'audioCodec ' => 'libvorbis ' ,
118+ 'audioCodec ' => 'libvorbis ' ,
91119 'audioCodecOptions ' => '-async 1000 ' ,
92120 ],
93121 'gif ' => [
94- 'fileSuffix ' => '.mp4 ' ,
95- 'fileFormat ' => 'mp4 ' ,
96- 'videoCodec ' => 'libx264 ' ,
97- 'videoCodecOptions ' => '-pix_fmt yuv420p -movflags +faststart -filter:v crop= \'floor(in_w/2)*2:floor(in_h/2)*2 \' ' ,
98- ]
122+ 'fileSuffix ' => '.mp4 ' ,
123+ 'fileFormat ' => 'mp4 ' ,
124+ 'videoCodec ' => 'libx264 ' ,
125+ 'videoCodecOptions ' => '-pix_fmt yuv420p -movflags +faststart -filter:v crop= \'floor(in_w/2)*2:floor(in_h/2)*2 \' ' ,
126+ ],
99127 ];
100128
101129 /**
@@ -105,22 +133,22 @@ class Settings extends Model
105133 */
106134 public $ audioEncoders = [
107135 'mp3 ' => [
108- 'fileSuffix ' => '.mp3 ' ,
109- 'fileFormat ' => 'mp3 ' ,
110- 'audioCodec ' => 'libmp3lame ' ,
136+ 'fileSuffix ' => '.mp3 ' ,
137+ 'fileFormat ' => 'mp3 ' ,
138+ 'audioCodec ' => 'libmp3lame ' ,
111139 'audioCodecOptions ' => '' ,
112140 ],
113141 'aac ' => [
114- 'fileSuffix ' => '.m4a ' ,
115- 'fileFormat ' => 'aac ' ,
116- 'audioCodec ' => 'libfdk_aac ' ,
142+ 'fileSuffix ' => '.m4a ' ,
143+ 'fileFormat ' => 'aac ' ,
144+ 'audioCodec ' => 'libfdk_aac ' ,
117145 'audioCodecOptions ' => '' ,
118146
119147 ],
120148 'ogg ' => [
121- 'fileSuffix ' => '.ogg ' ,
122- 'fileFormat ' => 'ogg ' ,
123- 'audioCodec ' => 'libvorbis ' ,
149+ 'fileSuffix ' => '.ogg ' ,
150+ 'fileFormat ' => 'ogg ' ,
151+ 'audioCodec ' => 'libvorbis ' ,
124152 'audioCodecOptions ' => '' ,
125153 ],
126154 ];
@@ -132,20 +160,20 @@ class Settings extends Model
132160 */
133161 public $ defaultVideoOptions = [
134162 // Video settings
135- 'videoEncoder ' => 'h264 ' ,
136- 'videoBitRate ' => '800k ' ,
137- 'videoFrameRate ' => 15 ,
163+ 'videoEncoder ' => 'h264 ' ,
164+ 'videoBitRate ' => '800k ' ,
165+ 'videoFrameRate ' => 15 ,
138166 // Audio settings
139- 'audioBitRate ' => '' ,
167+ 'audioBitRate ' => '' ,
140168 'audioSampleRate ' => '' ,
141- 'audioChannels ' => '' ,
169+ 'audioChannels ' => '' ,
142170 // Spatial settings
143- 'width ' => '' ,
144- 'height ' => '' ,
145- 'sharpen ' => true ,
171+ 'width ' => '' ,
172+ 'height ' => '' ,
173+ 'sharpen ' => true ,
146174 // Can be 'none', 'crop', or 'letterbox'
147- 'aspectRatio ' => 'letterbox ' ,
148- 'letterboxColor ' => '' ,
175+ 'aspectRatio ' => 'letterbox ' ,
176+ 'letterboxColor ' => '' ,
149177 ];
150178
151179 /**
@@ -154,13 +182,13 @@ class Settings extends Model
154182 * @var array
155183 */
156184 public $ defaultThumbnailOptions = [
157- 'fileSuffix ' => '.jpg ' ,
158- 'timeInSecs ' => 10 ,
159- 'width ' => '' ,
160- 'height ' => '' ,
161- 'sharpen ' => true ,
185+ 'fileSuffix ' => '.jpg ' ,
186+ 'timeInSecs ' => 10 ,
187+ 'width ' => '' ,
188+ 'height ' => '' ,
189+ 'sharpen ' => true ,
162190 // Can be 'none', 'crop', or 'letterbox'
163- 'aspectRatio ' => 'letterbox ' ,
191+ 'aspectRatio ' => 'letterbox ' ,
164192 'letterboxColor ' => '' ,
165193 ];
166194
@@ -170,10 +198,10 @@ class Settings extends Model
170198 * @var array
171199 */
172200 public $ defaultAudioOptions = [
173- 'audioEncoder ' => 'mp3 ' ,
174- 'audioBitRate ' => '128k ' ,
201+ 'audioEncoder ' => 'mp3 ' ,
202+ 'audioBitRate ' => '128k ' ,
175203 'audioSampleRate ' => '44100 ' ,
176- 'audioChannels ' => '2 ' ,
204+ 'audioChannels ' => '2 ' ,
177205 ];
178206
179207 /**
@@ -182,13 +210,13 @@ class Settings extends Model
182210 * @var array
183211 */
184212 public $ defaultGifOptions = [
185- ' videoEncoder ' => 'gif ' ,
186- 'fileSuffix ' => '' ,
187- 'fileFormat ' => '' ,
188- 'videoCodec ' => '' ,
213+ ' videoEncoder ' => 'gif ' ,
214+ 'fileSuffix ' => '' ,
215+ 'fileFormat ' => '' ,
216+ 'videoCodec ' => '' ,
189217 'videoCodecOptions ' => '' ,
190218 ];
191-
219+
192220 // Public Methods
193221 // =========================================================================
194222
0 commit comments