Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VMAF: Fix issues with json file names #13

Merged
merged 1 commit into from
Apr 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions Scripts/Flow/Video/Video - VMAF.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Calculate vmaf score of working file compared to original file
* @author Luigi311
* @revision 1
* @revision 2
* @minimumVersion 1.0.0.0
* @param {int} n_threads Amount of threads to use for calculation, 0 for auto (non windows only)
* @param {string} json_file Json file containing vmaf information, empty for ${Flow.TempPath}/${file.NameNoExtension}.json
Expand Down Expand Up @@ -34,10 +34,9 @@ function Script(n_threads, json_file)
Logger.ILog(`Setting n_threads to ${n_threads}`);
}

if(!json_file || String(json_file).trim().length === 0) {
Logger.ILog(`Setting json_file to ${Flow.TempPath}/${Variables.file.NameNoExtension}.json`)
json_file = `${Flow.TempPath}/${Variables.file.NameNoExtension}.json`;
}
// Set the default json file to a random guid to avoid issues with file names
// and move it to the correct name at the end
let temp_json_file = `${Flow.TempPath}/${Flow.NewGuid()}.json`;

let ffmpeg = Flow.GetToolPath('ffmpeg');
let vmaf_process = Flow.Execute({
Expand All @@ -56,7 +55,7 @@ function Script(n_threads, json_file)
'-i',
Variables.file.Orig.FullName,
'-lavfi',
`libvmaf=n_threads=${n_threads}:log_fmt=json:log_path='${json_file}'`,
`libvmaf=n_threads=${n_threads}:log_fmt=json:log_path='${temp_json_file}'`,
'-f',
'null',
'-'
Expand Down Expand Up @@ -90,5 +89,12 @@ function Script(n_threads, json_file)
Logger.ILog("VMAF Score: " + vmaf);
Variables.VMAF = parseFloat(vmaf);

if(!json_file || String(json_file).trim().length === 0) {
Logger.ILog(`Setting json_file to ${Flow.TempPath}/${Variables.file.NameNoExtension}.json`)
json_file = `${Flow.TempPath}/${Variables.file.NameNoExtension}.json`;
}

System.IO.File.Move(temp_json_file, json_file);

return 1;
}
Loading