Skip to content

Commit ede75ab

Browse files
authored
Merge pull request #16 from Rias500/v1
Allow setting threads in config
2 parents 23ad437 + 36a7d3d commit ede75ab

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/config.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
'videoCodecOptions' => '-vprofile high -preset slow -crf 22',
6767
'audioCodec' => 'libfdk_aac',
6868
'audioCodecOptions' => '-async 1000',
69+
'threads' => '0',
6970
],
7071
'webm' => [
7172
'fileSuffix' => '.webm',
@@ -74,12 +75,14 @@
7475
'videoCodecOptions' => '-quality good -cpu-used 0',
7576
'audioCodec' => 'libvorbis',
7677
'audioCodecOptions' => '-async 1000',
78+
'threads' => '0',
7779
],
7880
'gif' => [
7981
'fileSuffix' => '.mp4',
8082
'fileFormat' => 'mp4',
8183
'videoCodec' => 'libx264',
8284
'videoCodecOptions' => '-pix_fmt yuv420p -movflags +faststart -filter:v crop=\'floor(in_w/2)*2:floor(in_h/2)*2\' ',
85+
'threads' => '0',
8386
],
8487
],
8588

@@ -90,19 +93,22 @@
9093
'fileFormat' => 'mp3',
9194
'audioCodec' => 'libmp3lame',
9295
'audioCodecOptions' => '',
96+
'threads' => '0',
9397
],
9498
'aac' => [
9599
'fileSuffix' => '.m4a',
96100
'fileFormat' => 'aac',
97101
'audioCodec' => 'libfdk_aac',
98102
'audioCodecOptions' => '',
103+
'threads' => '0',
99104

100105
],
101106
'ogg' => [
102107
'fileSuffix' => '.ogg',
103108
'fileFormat' => 'ogg',
104109
'audioCodec' => 'libvorbis',
105110
'audioCodecOptions' => '',
111+
'threads' => '0',
106112
],
107113
],
108114

src/models/Settings.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public function __construct(array $config = [])
118118
'videoCodecOptions' => '-vprofile high -preset slow -crf 22',
119119
'audioCodec' => 'libfdk_aac',
120120
'audioCodecOptions' => '-async 1000',
121+
'threads' => '0',
121122
],
122123
'webm' => [
123124
'fileSuffix' => '.webm',
@@ -126,12 +127,14 @@ public function __construct(array $config = [])
126127
'videoCodecOptions' => '-quality good -cpu-used 0',
127128
'audioCodec' => 'libvorbis',
128129
'audioCodecOptions' => '-async 1000',
130+
'threads' => '0',
129131
],
130132
'gif' => [
131133
'fileSuffix' => '.mp4',
132134
'fileFormat' => 'mp4',
133135
'videoCodec' => 'libx264',
134136
'videoCodecOptions' => '-pix_fmt yuv420p -movflags +faststart -filter:v crop=\'floor(in_w/2)*2:floor(in_h/2)*2\' ',
137+
'threads' => '0',
135138
],
136139
];
137140

@@ -146,19 +149,22 @@ public function __construct(array $config = [])
146149
'fileFormat' => 'mp3',
147150
'audioCodec' => 'libmp3lame',
148151
'audioCodecOptions' => '',
152+
'threads' => '0',
149153
],
150154
'aac' => [
151155
'fileSuffix' => '.m4a',
152156
'fileFormat' => 'aac',
153157
'audioCodec' => 'libfdk_aac',
154158
'audioCodecOptions' => '',
159+
'threads' => '0',
155160

156161
],
157162
'ogg' => [
158163
'fileSuffix' => '.ogg',
159164
'fileFormat' => 'ogg',
160165
'audioCodec' => 'libvorbis',
161166
'audioCodecOptions' => '',
167+
'threads' => '0',
162168
],
163169
];
164170

src/services/Transcode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function getVideoUrl($filePath, $videoOptions): string
112112
.' -vcodec '.$thisEncoder['videoCodec']
113113
.' '.$thisEncoder['videoCodecOptions']
114114
.' -bufsize 1000k'
115-
.' -threads 0';
115+
.' -threads '.$thisEncoder['threads'];
116116

117117
// Set the framerate if desired
118118
if (!empty($videoOptions['videoFrameRate'])) {
@@ -319,7 +319,7 @@ public function getAudioUrl($filePath, $audioOptions): string
319319
.' -acodec '.$thisEncoder['audioCodec']
320320
.' '.$thisEncoder['audioCodecOptions']
321321
.' -bufsize 1000k'
322-
.' -threads 0';
322+
.' -threads '.$thisEncoder['threads'];
323323

324324
// Set the bitrate if desired
325325
if (!empty($audioOptions['audioBitRate'])) {

0 commit comments

Comments
 (0)