Skip to content

Commit

Permalink
feat: command for running VMAF on arbitrary files using configured pi…
Browse files Browse the repository at this point in the history
…peline

Signed-off-by: Gustav Grusell <[email protected]>
  • Loading branch information
grusell committed Sep 16, 2024
1 parent 17b5e6f commit 54848a0
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ Commands:
videofile source [default]
autovmaf suggest-ladder <folder> Suggest bitrate ladder given vmaf results
autovmaf export-csv <folder> Export Vmaf results as csv
autovmaf vmaf Use pipeline to run VMAF for the given
distorted and reference files

Positionals:
source SOURCEFILE [string]
Expand Down Expand Up @@ -307,6 +309,25 @@ Options:
If your job uses variables ([See above](#using-variables-in-the-job-definition)), the variables that should
be included in the csv data should be specified with the `--variables` option.
### Run VMAF only
This command allows using a configured pipeline to run VMAF measurements on any files without an related autovmaf job.
In case of an aws pipeline, output will be written to the `outputBucket` configured in the pipeline.
```
autovmaf vmaf

Use pipeline to run VMAF for the given distorted and reference files

Options:
--version Show version number [boolean]
--help Show help [boolean]
--pipeline Path to pipeline file [string] [required]
--reference Uri or path to reference file [string] [required]
--distorted Uri or path to distorted file [string] [required]
--model VMAF model to use [string] [default: "HD"]
```
## Development
### Run tests
Expand Down
52 changes: 52 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import suggestLadder from './suggest-ladder';
import ObjectsToCsv from 'objects-to-csv';
import { pairVmafWithResolutionAndBitrate } from './pairVmaf';
import { VmafBitratePair } from './models/vmaf-bitrate-pair';
import { loadPipeline } from './load-pipeline';
import {
QualityAnalysisModel,
stringToQualityAnalysisModel
} from './models/quality-analysis-model';

class ValidationError extends Error {
constructor(message) {
Expand Down Expand Up @@ -133,10 +138,57 @@ async function run() {
},
exportWmafResultToCsv
)
.command(
'vmaf',
'Use pipeline to run VMAF for the given distorted and reference files',
(yargs) => {
return yargs.options({
pipeline: {
type: 'string',
description: 'Path to pipeline file',
required: true
},
reference: {
type: 'string',
description: 'Uri or path to reference file',
required: true
},
distorted: {
type: 'string',
description: 'Uri or path to distorted file',
required: true
},
model: {
type: 'string',
description: 'VMAF model to use',
default: 'HD'
}
});
},
runVmaf
)
.help()
.parse();
}

async function runVmaf(argv) {
const reference = argv.reference;
const distorted = argv.distorted;
const pipeline = await loadPipeline(argv.pipeline);
const qualityFile = argv.distorted.replace('.mp4', '_vmaf.json');
const model: QualityAnalysisModel = stringToQualityAnalysisModel(argv.model);
const jobDescription = `${model},${reference},${distorted},${qualityFile}`;
pipeline
.analyzeQuality(reference, distorted, qualityFile, model)
.then(() => {
logger.info(`Finished VMAF measurement for ${jobDescription}`);
})
.catch((err) => {
logger.error(`Error running VMAF for ${jobDescription}: ${err}`);
});
logger.info(`Started VMAF measurement for ${jobDescription}`);
}

async function runSuggestLadder(argv) {
const { ladder, pairs } = await suggestLadder(argv.folder);
logger.info(`ladder: ${ladder}`);
Expand Down

0 comments on commit 54848a0

Please sign in to comment.