1 Commits

Author SHA1 Message Date
Michael Fabian 'Xaymar' Dirks dee9eed566 1.1.1: Fix filter chain and libvmaf input order
- The order of inputs to libvmaf is distorted, then reference. Earlier versions had this inverted accidentally.
- Format conversion now happens after color conversion and scaling, and now supports the optional argument.
2022-12-27 16:11:49 +01:00
2 changed files with 32 additions and 27 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "js-vmaf", "name": "js-vmaf",
"version": "1.1.0", "version": "1.1.1",
"description": "A simple tool to quickly and correctly compare a reference file with a distorted file using VMAF.", "description": "A simple tool to quickly and correctly compare a reference file with a distorted file using VMAF.",
"main": "generated/index.js", "main": "generated/index.js",
"scripts": { "scripts": {
+31 -26
View File
@@ -257,6 +257,26 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AN
chain.push(`fps=${valueOrDefault(this._args.fps, fref.video[0].r_framerate)}`); chain.push(`fps=${valueOrDefault(this._args.fps, fref.video[0].r_framerate)}`);
} }
// Convert color.
if (this._args.color_space
|| this._args.color_primaries
|| this._args.color_trc
|| this._args.color_range
|| (this._ref.video[0].color_space !== fref.video[0].color_space)
|| (this._ref.video[0].color_primaries !== fref.video[0].color_primaries)
|| (this._ref.video[0].color_transfer !== fref.video[0].color_transfer)
|| (this._ref.video[0].color_range !== fref.video[0].color_range)) {
chain.push("colorspace=dither=fsb" +
`:ispace=${valueOrDefault(this._ref.video[0].color_space, "bt709")}` +
`:iprimaries=${valueOrDefault(this._ref.video[0].color_primaries, "bt709")}` +
`:itrc=${valueOrDefault(this._ref.video[0].color_transfer, "bt709")}` +
`:irange=${valueOrDefault(this._ref.video[0].color_range, "tv")}` +
`:space=${valueOrDefault(this._args.color_space, valueOrDefault(fref.video[0].color_space, "bt709"))}` +
`:primaries=${valueOrDefault(this._args.color_primaries, valueOrDefault(fref.video[0].color_primaries, "bt709"))}` +
`:trc=${valueOrDefault(this._args.color_trc, valueOrDefault(fref.video[0].color_transfer, "bt709"))}` +
`:range=${valueOrDefault(this._args.color_range, valueOrDefault(fref.video[0].color_range, "tv"))}`);
}
// Scale // Scale
if (this._args.width if (this._args.width
|| this._args.height) { || this._args.height) {
@@ -276,26 +296,9 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AN
); );
} }
// Convert format and color. // Convert format.
if (this._args.color_space if (this._args.format || (this._ref.video[0].pix_fmt !== fref.video[0].pix_fmt)) {
|| this._args.color_primaries chain.push(`format=pix_fmts=${valueOrDefault(this._args.format, valueOrDefault(fref.video[0].pix_fmt, "yuv420p"))}`)
|| this._args.color_trc
|| this._args.color_range
|| (this._ref.video[0].pix_fmt !== fref.video[0].pix_fmt)
|| (this._ref.video[0].color_space !== fref.video[0].color_space)
|| (this._ref.video[0].color_primaries !== fref.video[0].color_primaries)
|| (this._ref.video[0].color_transfer !== fref.video[0].color_transfer)
|| (this._ref.video[0].color_range !== fref.video[0].color_range)) {
chain.push("colorspace=dither=fsb" +
`:ispace=${valueOrDefault(this._ref.video[0].color_space, "bt709")}` +
`:iprimaries=${valueOrDefault(this._ref.video[0].color_primaries, "bt709")}` +
`:itrc=${valueOrDefault(this._ref.video[0].color_transfer, "bt709")}` +
`:irange=${valueOrDefault(this._ref.video[0].color_range, "tv")}` +
`:space=${valueOrDefault(this._args.color_space, valueOrDefault(fref.video[0].color_space, "bt709"))}` +
`:primaries=${valueOrDefault(this._args.color_primaries, valueOrDefault(fref.video[0].color_primaries, "bt709"))}` +
`:trc=${valueOrDefault(this._args.color_trc, valueOrDefault(fref.video[0].color_transfer, "bt709"))}` +
`:range=${valueOrDefault(this._args.color_range, valueOrDefault(fref.video[0].color_range, "tv"))}` +
`:format=${valueOrDefault(this._args.format, valueOrDefault(fref.video[0].pix_fmt, "yuv420p"))}`);
} }
filters.push(`[0:v:0]${chain.join(",")}[ref]`); filters.push(`[0:v:0]${chain.join(",")}[ref]`);
@@ -316,7 +319,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AN
|| this._args.color_primaries || this._args.color_primaries
|| this._args.color_trc || this._args.color_trc
|| this._args.color_range || this._args.color_range
|| (cmp.video[0].pix_fmt !== fref.video[0].pix_fmt)
|| (cmp.video[0].color_space !== fref.video[0].color_space) || (cmp.video[0].color_space !== fref.video[0].color_space)
|| (cmp.video[0].color_primaries !== fref.video[0].color_primaries) || (cmp.video[0].color_primaries !== fref.video[0].color_primaries)
|| (cmp.video[0].color_transfer !== fref.video[0].color_transfer) || (cmp.video[0].color_transfer !== fref.video[0].color_transfer)
@@ -329,8 +331,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AN
`:space=${valueOrDefault(this._args.color_space, valueOrDefault(fref.video[0].color_space, "bt709"))}` + `:space=${valueOrDefault(this._args.color_space, valueOrDefault(fref.video[0].color_space, "bt709"))}` +
`:primaries=${valueOrDefault(this._args.color_primaries, valueOrDefault(fref.video[0].color_primaries, "bt709"))}` + `:primaries=${valueOrDefault(this._args.color_primaries, valueOrDefault(fref.video[0].color_primaries, "bt709"))}` +
`:trc=${valueOrDefault(this._args.color_trc, valueOrDefault(fref.video[0].color_transfer, "bt709"))}` + `:trc=${valueOrDefault(this._args.color_trc, valueOrDefault(fref.video[0].color_transfer, "bt709"))}` +
`:range=${valueOrDefault(this._args.color_range, valueOrDefault(fref.video[0].color_range, "tv"))}` + `:range=${valueOrDefault(this._args.color_range, valueOrDefault(fref.video[0].color_range, "tv"))}`);
`:format=${valueOrDefault(this._args.format, valueOrDefault(fref.video[0].pix_fmt, "yuv420p"))}`);
} }
// Scale // Scale
@@ -352,6 +353,11 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AN
); );
} }
// Convert format.
if (this._args.format || (cmp.video[0].pix_fmt !== fref.video[0].pix_fmt)) {
chain.push(`format=pix_fmts=${valueOrDefault(this._args.format, valueOrDefault(fref.video[0].pix_fmt, "yuv420p"))}`)
}
filters.push(`[1:v:0]${chain.join(",")}[dst]`); filters.push(`[1:v:0]${chain.join(",")}[dst]`);
} }
@@ -368,7 +374,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AN
chain.push(`feature=${this._args.feature.join("|").replace(/([\\"'`:]{1,1})/g, "\\\\$1")}`); chain.push(`feature=${this._args.feature.join("|").replace(/([\\"'`:]{1,1})/g, "\\\\$1")}`);
} }
chain.push(`n_threads=${this._args.threads}`); chain.push(`n_threads=${this._args.threads}`);
filters.push(`[ref][dst]libvmaf=${chain.join(":")}`); filters.push(`[dst][ref]libvmaf=${chain.join(":")}`);
const proc = this.FFmpeg([ const proc = this.FFmpeg([
"-hide_banner", "-hide_banner",
@@ -460,9 +466,8 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AN
} }
public async run() : Promise<number> { public async run() : Promise<number> {
this._args = this._argparse.parse_known_args();
this.license();
this._args = this._argparse.parse_args(); this._args = this._argparse.parse_args();
this.license();
//if (!this._args.quiet) console.dir(this._args); //if (!this._args.quiet) console.dir(this._args);