You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- The `ffmpeg` progress for video transcoding is now written out to a `.progress` file
- Added a `progress` controller to return video transcoding progress
- Moved all of the default settings out to the `config.php` file
Copy file name to clipboardExpand all lines: LICENSE.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,9 @@
1
-
The MIT License (MIT)
2
-
1
+
The Transcoder License
3
2
Copyright (c) 2017 nystudio107
4
3
5
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
Permission is hereby granted, free of charge, to any person or entity obtaining a copy of this software and associated documentation files (the "Software"), to use the software in any capacity, including commercial and for-profit use. Permission is also granted to alter, modify, or extend the Software for your own use, or commission a third-party to perform modifications for you.
5
+
6
+
Permission is NOT granted to create derivative works, sublicense, and/or sell copies of the Software. This is not FOSS software.
6
7
7
8
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
@@ -8,14 +8,23 @@ Related: [Transcoder for Craft 2.x](https://github.com/nystudio107/transcoder)
8
8
9
9
To install Transcoder, follow these steps:
10
10
11
-
3. Install with Composer via `composer require nystudio107/craft3-transcoder`
12
-
4. Install plugin in the Craft Control Panel under Settings > Plugins
11
+
1. Install with Composer via `composer require nystudio107/craft3-transcoder`
12
+
2. Install plugin in the Craft Control Panel under Settings > Plugins
13
13
14
14
Transcoder works on Craft 3.x.
15
15
16
+
You will also need [ffmpeg](https://ffmpeg.org/) installed for Transcoder to work. On Ubuntu 16.04, you can do just:
17
+
18
+
sudo apt-get update
19
+
sudo apt-get install ffmpeg
20
+
21
+
To install `ffmpeg` on Centos 6/7, you can follow the guide [How to Install FFmpeg on CentOS](https://www.vultr.com/docs/how-to-install-ffmpeg-on-centos)
22
+
23
+
If you have managed hosting, contact your sysadmin to get `ffmpeg` installed.
24
+
16
25
## Transcoder Overview
17
26
18
-
The Transcoder video allows you to take any locally stored video, and transcode it into any bitrate/framerate, and save it out as a web-ready `.mp4` file.
27
+
The Transcoder video allows you to take any locally stored video, and transcode it into any size, bitrate, framerate, and save it out as a web-ready `.mp4` file.
19
28
20
29
It also allows you to get a thumbnail of the video in any size and at any timecode.
21
30
@@ -57,12 +66,43 @@ The only configuration for Transcoder is in the `config.php` file, which is a mu
@@ -71,17 +111,21 @@ The only configuration for Transcoder is in the `config.php` file, which is a mu
71
111
72
112
To generate a transcoded video, do the following:
73
113
74
-
{% set transVideoUrl = craft.transcoder.getVideoUrl('/home/vagrant/sites/nystudio107/public/trimurti.mp4', {
114
+
{% set transVideoUrl = craft.transcoder.getVideoUrl('/home/vagrant/sites/nystudio107/public/oceans.mp4', {
75
115
"frameRate": 20,
76
-
"bitRate": "500k"
116
+
"bitRate": "500k",
117
+
"width": 720,
118
+
"height": 480
77
119
}) %}
78
120
79
-
You can also pass in an `AssetFileModel`:
121
+
You can also pass in an `Asset`:
80
122
81
123
{% set myAsset = entry.someAsset.first() %}
82
124
{% set transVideoUrl = craft.transcoder.getVideoUrl(myAsset, {
83
125
"frameRate": 20,
84
-
"bitRate": "500k"
126
+
"bitRate": "500k",
127
+
"width": 720,
128
+
"height": 480
85
129
}) %}
86
130
87
131
It will return to you a URL to the transcoded video if it already exists, or if it doesn't exist, it will return `""` and kick off the transcoding process (which can be quite lengthy for long videos).
@@ -91,8 +135,12 @@ In the array you pass in, the default values are used if the key/value pair does
91
135
{
92
136
"bitRate" => "800k",
93
137
"frameRate" => 15,
138
+
"aspectRatio" => "letterbox",
139
+
"sharpen" => true,
94
140
}
95
141
142
+
These default values come from the `config.php` file.
143
+
96
144
If you want to have the Transcoder not change a parameter, pass in an empty value in the key/value pair, e.g.:
97
145
98
146
{% set transVideoUrl = craft.transcoder.getVideoUrl('/home/vagrant/sites/nystudio107/public/trimurti.mp4', {
@@ -102,11 +150,69 @@ If you want to have the Transcoder not change a parameter, pass in an empty valu
102
150
103
151
The above example would cause it to not change the frameRate or bitRate of the source movie (not recommended for client-proofing purposes).
104
152
153
+
The `aspectRatio` parameter lets you control how the video aspect ratio is maintained when it is scaled:
154
+
155
+
`none` results in the aspect ratio of the original video not being maintained, and the video scaled to the dimensions passed in:
You can control the color of the letterboxed area (it's `black` by default) via the `letterboxColor` option. It can be either a semantic color name, or a hexcode color, e.g.: `0xC0C0C0`
168
+
169
+
The `sharpen` option determines whether an unsharp mask filter should be applied to the scaled video.
170
+
171
+
### Getting Transcoding Progress
172
+
173
+
Transcoding of videos can take quite a bit of time, so Transcoder provides you with a way to get the status of any currently running transcoding operation via `craft.transcoder.getVideoProgressUrl()`. For example:
174
+
175
+
{% set myAsset = entry.someAsset.first() %}
176
+
{% set videoOptions = {
177
+
"frameRate": 60,
178
+
"bitRate": "1000k",
179
+
"width": 1000,
180
+
"height": 800,
181
+
"aspectRatio": "none",
182
+
} %}
183
+
{% set transVideoUrl = craft.transcoder.getVideoUrl(myAsset, videoOptions) %}
184
+
{% set progressUrl = craft.transcoder.getVideoProgressUrl(myAsset, videoOptions) %}
185
+
186
+
The variable `progressUrl` in the example above is set to a URL will return a JSON array of data indicating the current progress of the transcoding:
You can control the color of the letterboxed area (it's `black` by default) via the `letterboxColor` option. It can be either a semantic color name, or a hexcode color, e.g.: `0xC0C0C0`
258
+
259
+
The `sharpen` option determines whether an unsharp mask filter should be applied to the scaled thumbnail image.
260
+
261
+
### Getting Information About a Video
262
+
263
+
To get information about an existing video, you can use `craft.transcoder.getFileInfo()`:
264
+
265
+
{% set transVideoUrl = craft.transcoder.getFileInfo('/home/vagrant/sites/nystudio107/public/oceans.mp4') %}
266
+
267
+
You can also pass in an `Asset`:
268
+
269
+
{% set myAsset = entry.someAsset.first() %}
270
+
{% set transVideoUrl = craft.transcoder.getFileInfo(myAsset) %}
271
+
272
+
This returns an array with two top-level keys:
273
+
274
+
*`format` - information about the container file format
275
+
*`streams` - information about each stream in the container; many videos have multiple streams, for instance, one for the video streams, and another for the audio stream. There can even be multiple video or audio streams in a container.
276
+
277
+
Here's example output from `craft.transcoder.getFileInfo`:
0 commit comments