Skip to content

Commit 1a0bb06

Browse files
committed
fix: fix x265/hevc 2 pass options.
1 parent e544dcf commit 1a0bb06

File tree

3 files changed

+62
-37
lines changed

3 files changed

+62
-37
lines changed

package-lock.json

Lines changed: 46 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ffmpeg-commander",
3-
"version": "0.7.1",
3+
"version": "0.7.2",
44
"scripts": {
55
"serve": "vue-cli-service serve",
66
"build": "vue-cli-service build",

src/ffmpeg.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,24 @@ function setAudioFilters(options) {
175175
return af.join(',');
176176
}
177177

178-
function set2Pass(flags) {
178+
function set2Pass(flags, options) {
179179
const op = '/dev/null &&'; // For Windows use `NUL && \`
180180
const copy = flags.slice(); // Array clone for pass 2.
181181

182182
// Rewrite command with 1 and 2 pass flags and append to flags array.
183-
flags.push(...['-pass', '1', op]);
184-
copy.push(...['-pass', '2']);
183+
if (options.vcodec === 'libx265' && options.codecOptions) {
184+
// Add pass param if the -x265-params flag is already present.
185+
const idx = flags.indexOf('-x265-params');
186+
// eslint-disable-next-line no-param-reassign
187+
flags[idx + 1] += ':pass=1';
188+
copy[idx + 1] += ':pass=2';
189+
} else if (options.vcodec === 'libx265') {
190+
flags.push(...['-x265-params', 'pass=1', op]);
191+
copy.push(...['-x265-params', 'pass=2']);
192+
} else {
193+
flags.push(...['-pass', '1', op]);
194+
copy.push(...['-pass', '2']);
195+
}
185196
return copy;
186197
}
187198

@@ -274,7 +285,7 @@ function build(opt) {
274285

275286
// Set 2 pass output if option is set.
276287
if (options.pass === '2') {
277-
const copy = set2Pass(flags);
288+
const copy = set2Pass(flags, options);
278289
flags.push(...copy);
279290
}
280291

0 commit comments

Comments
 (0)