Skip to content

Commit

Permalink
Merge pull request #56 from lawrencecurtis/dovi-change-detection
Browse files Browse the repository at this point in the history
[Dovi fix] Change detection logic
  • Loading branch information
revenz authored Sep 16, 2024
2 parents 070aa42 + 83bc136 commit b98ff43
Showing 1 changed file with 34 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Run between encode and move/replace.
Output is always an MKV.
dovi_tool only supports HEVC when AV1 support is added I will updated this script.
* @author Lawrence Curtis
* @revision 1
* @revision 2
* @uid f5eebc75-e22d-4181-af02-5e7263e68acd
* @param {bool} RemoveHDRTenPlus Remove HDR10+, this fixes the black screen issues on FireStick
* @output Fixed
Expand All @@ -16,16 +16,9 @@ function Script(RemoveHDRTenPlus) {
const duration = Variables.vi.Duration;
const videoStreams = Variables.vi.VideoInfo.VideoStreams;

if (!(videoStreams?.length > 0 && videoStreams[0].DolbyVision)) {
Logger.ELog("No Dolby Vision detected");
return 2;
}

if (!(videoStreams[0].Codec == "hevc")) {
Logger.ELog(
"Video format MUST be HEVC, AV1 is not currently supported by dovi_tool"
);
return 2;
if (!videoStreams?.length) {
Logger.ELog("No Video detected");
return -1;
}

Flow.AdditionalInfoRecorder("DoVi", "Initializing", 1);
Expand All @@ -45,12 +38,32 @@ function Script(RemoveHDRTenPlus) {
let working = Flow.WorkingFile;
let original = Variables.file.Orig.FullName;

let process = Flow.Execute({
command: ffmpeg,
argumentList: ["-i", original],
});

let regexp = /DOVI configuration/i;
let matches = process.standardOutput.match(regexp);

if (!matches) return 2;

if (!(videoStreams[0].Codec == "hevc")) {
Logger.ELog(
"Video format MUST be HEVC, AV1 is not currently supported by dovi_tool"
);
return -1;
}

Flow.AdditionalInfoRecorder("DoVi", "Extracting HEVC bitstream", 1);

var executeArgs = new ExecuteArgs();

executeArgs.command = ffmpeg;
executeArgs.argumentList = [
"-v",
"quiet",
"-stats",
"-i",
original,
"-c:v",
Expand All @@ -69,7 +82,7 @@ function Script(RemoveHDRTenPlus) {
}
});

let process = Flow.Execute(executeArgs);
process = Flow.Execute(executeArgs);

if (process.exitCode !== 0) {
Logger.ELog("Failed to extract HEVC: " + process.output);
Expand Down Expand Up @@ -130,10 +143,17 @@ function Script(RemoveHDRTenPlus) {

executeArgs.command = ffmpeg;
executeArgs.argumentList = [
"-v",
"quiet",
"-stats",
"-i",
working,
"-c:v",
"copy",
"-bsf:v",
"hevc_mp4toannexb",
"-f",
"hevc",
Flow.TempPath + "/converted_video.hevc",
];

Expand Down Expand Up @@ -208,8 +228,8 @@ function Script(RemoveHDRTenPlus) {
argumentList: [working],
});

const regexp = /([\.0-9]+) frames\/fields/i;
const matches = process.standardOutput.match(regexp);
regexp = /([\.0-9]+) frames\/fields/i;
matches = process.standardOutput.match(regexp);
var executeArgs = new ExecuteArgs();

executeArgs.command = mkvmerge;
Expand Down

0 comments on commit b98ff43

Please sign in to comment.