5 Commits

Author SHA1 Message Date
dependabot[bot] c0d30550a6 Bump word-wrap from 1.2.3 to 1.2.4
Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4.
- [Release notes](https://github.com/jonschlinkert/word-wrap/releases)
- [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4)

---
updated-dependencies:
- dependency-name: word-wrap
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-21 13:08:35 +02:00
Michael Fabian 'Xaymar' Dirks 2735d7b0c6 1.1.2: Fix some bugs regarding frame rate
- r_framerate doesn't exist, but r_frame_rate does.
- FFmpeg may misidentify CFR streams as pseudo-VFR, need to force it into the correct mode.
2023-01-09 11:22:57 +01:00
Michael Fabian 'Xaymar' Dirks 41989579f2 Fix framerate override and force CFR on pseudo-VFR content
Can't exactly support VFR :/
2023-01-09 11:21:45 +01:00
Michael Fabian 'Xaymar' Dirks 3f57e8b399 Add missing VSCode workspace file 2023-01-09 11:19:24 +01:00
Michael Fabian 'Xaymar' Dirks 67c85f5df8 Improve README 2022-12-27 16:34:07 +01:00
5 changed files with 93 additions and 22 deletions
+62 -5
View File
@@ -1,19 +1,76 @@
# js-vmaf: Simple, but effective VMAF comparison tool
This is a simple wrapper around FFmpeg and VMAF to handle comparison of files.
```
$node . --help
usage: js-vmaf [--help] [--hide_banner] [-q] [-v] --ffmpeg FFMPEG --ffprobe FFPROBE [--vmaf VMAF] -r
REFERENCE [-o OUTPUT] [--flip] [-cs COLOR_SPACE] [-cp COLOR_PRIMARIES] [-ct COLOR_TRC]
[-cr COLOR_RANGE] [-p FORMAT] [-w WIDTH] [-h HEIGHT] [--fps FPS] [-f FEATURE] [-m MODEL]
[-t THREADS]
Path [Path ...]
A simple, yet effective tool to quickly compare one or more videos using VMAF.
positional arguments:
Path One or more paths to a distorted file or a directory containing distorted files.
optional arguments:
--help show this help message and exit
--hide_banner Hide license banner.
-q, --quiet Be quiet.
-v, --verbose Be verbose.
--ffmpeg FFMPEG Path to the FFmpeg binary to use.
--ffprobe FFPROBE Path to the FFprobe binary to use.
--vmaf VMAF Path to the VMAF binary to use. Will fall back to FFmpeg if not provided
-r REFERENCE, --reference REFERENCE
Reference file
-o OUTPUT, --output OUTPUT
The file name, including formatters, for the output log file.
--flip Scale, convert and resample to distorted file instead of reference file.
-cs COLOR_SPACE, --color_space COLOR_SPACE
Define the color space of the reference file.
-cp COLOR_PRIMARIES, --color_primaries COLOR_PRIMARIES
Define the color primaries of the reference file.
-ct COLOR_TRC, --color_trc COLOR_TRC
Define the color transfer characteristics of the reference file.
-cr COLOR_RANGE, --color_range COLOR_RANGE
Define the color range of the reference file.
-p FORMAT, --format FORMAT
Define the format for comparison.
-w WIDTH, --width WIDTH
Define the width for the comparision.
-h HEIGHT, --height HEIGHT
Define the height for the comparision.
--fps FPS Define the FPS for comparison.
-f FEATURE, --feature FEATURE
Enable (and configure) a feature
-m MODEL, --model MODEL
Enable (and configure) a model
-t THREADS, --threads THREADS
Number of threads to use.
```
## Installing
```
npm install
npm run build
```
## Usage
## Examples
##### Compare all files in a directory
```
node . --help
$(prog) --ffmpeg ffmpeg --ffprobe ffprobe -r /mnt/usb0/ref.mp4 /mnt/usb1/
```
## Examples
### Compare all files in a directory
##### Use the distorted files as the target size
The following command converts the reference to the same format, resolution, framerate and color as the distorted files. Ideal for bitrate optimization.
```
node . --ffmpeg ./ffmpeg --ffprobe ./ffprobe -r /mnt/usb0/reference.mp4 /mnt/usb1/
$(prog) --ffmpeg ffmpeg --ffprobe ffprobe --flip -r /mnt/usb0/ref.mp4 /mnt/usb1/
```
##### Resize everything to 1080p and convert to yuv420p
```
$(prog) --ffmpeg ffmpeg --ffprobe ffprobe -h 1080 -p yuv420p -r /mnt/usb0/ref.mp4 /mnt/usb1/
```
+8
View File
@@ -0,0 +1,8 @@
{
"folders": [
{
"path": "."
}
],
"settings": {}
}
+8 -8
View File
@@ -1,12 +1,12 @@
{
"name": "js-vmaf",
"version": "1.0.1",
"version": "1.1.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "js-vmaf",
"version": "1.0.1",
"version": "1.1.2",
"license": "BSD 3-Clause \"New\" or \"Revised\" License",
"dependencies": {
"argparse": "^2.0.1",
@@ -1573,9 +1573,9 @@
}
},
"node_modules/word-wrap": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
"integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==",
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.4.tgz",
"integrity": "sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==",
"dev": true,
"engines": {
"node": ">=0.10.0"
@@ -2694,9 +2694,9 @@
}
},
"word-wrap": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
"integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==",
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.4.tgz",
"integrity": "sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==",
"dev": true
},
"wrappy": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "js-vmaf",
"version": "1.1.1",
"version": "1.1.2",
"description": "A simple tool to quickly and correctly compare a reference file with a distorted file using VMAF.",
"main": "generated/index.js",
"scripts": {
+14 -8
View File
@@ -253,8 +253,8 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AN
chain.push("setpts=PTS-STARTPTS");
// Convert to the correct framerate.
if (this._args.fps || (this._ref.video[0].r_framerate !== fref.video[0].r_framerate)) {
chain.push(`fps=${valueOrDefault(this._args.fps, fref.video[0].r_framerate)}`);
if (this._args.fps || (this._ref.video[0].r_frame_rate !== fref.video[0].r_frame_rate)) {
chain.push(`fps=${valueOrDefault(this._args.fps, fref.video[0].r_frame_rate)}`);
}
// Convert color.
@@ -298,7 +298,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AN
// Convert format.
if (this._args.format || (this._ref.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"))}`)
chain.push(`format=pix_fmts=${valueOrDefault(this._args.format, valueOrDefault(fref.video[0].pix_fmt, "yuv420p"))}`);
}
filters.push(`[0:v:0]${chain.join(",")}[ref]`);
@@ -310,8 +310,8 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AN
chain.push("setpts=PTS-STARTPTS");
// Convert to the correct framerate.
if (this._args.fps || (cmp.video[0].r_framerate !== fref.video[0].r_framerate)) {
chain.push(`fps=${valueOrDefault(this._args.fps, fref.video[0].r_framerate)}`);
if (this._args.fps || (cmp.video[0].r_frame_rate !== fref.video[0].r_frame_rate)) {
chain.push(`fps=${valueOrDefault(this._args.fps, fref.video[0].r_frame_rate)}`);
}
// Convert format and color.
@@ -355,7 +355,7 @@ 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"))}`)
chain.push(`format=pix_fmts=${valueOrDefault(this._args.format, valueOrDefault(fref.video[0].pix_fmt, "yuv420p"))}`);
}
filters.push(`[1:v:0]${chain.join(",")}[dst]`);
@@ -380,16 +380,19 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AN
"-hide_banner",
"-v", "quiet",
"-stats",
"-hwaccel", "auto",
"-threads", this._args.threads,
"-strict", "strict",
"-hwaccel", "auto",
"-hwaccel_flags", "+allow_high_depth",
"-r", this._ref.video[0].r_frame_rate,
"-i", this._args.reference,
"-threads", this._args.threads,
"-strict", "strict",
"-hwaccel", "auto",
"-hwaccel_flags", "+allow_high_depth",
"-r", cmp.video[0].r_frame_rate,
"-i", path,
"-sws_flags", "bicubic+full_chroma_inp+full_chroma_int",
@@ -401,7 +404,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AN
"-f", "null", OS.platform() === "win32" ? "NUL" : "/dev/null"
]);
await new Promise((resolve, reject) => {
const result : any = await new Promise((resolve, reject) => {
const sout : Array<string> = [];
const serr : Array<string> = [];
proc.addListener("exit", (code) => {
@@ -433,6 +436,9 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AN
});
});
});
if (result.code !== 0) {
throw new Error("Unexpected failure running FFmpeg");
}
}
if (PATH.extname(log) === ".json") {