refactor: create a function handle_fel_detection
to reduce code duplication
This commit is contained in:
parent
85641b680d
commit
075a370b71
90
dv_check.py
90
dv_check.py
@ -241,6 +241,35 @@ def create_fel(
|
|||||||
return el_mkv_output_path
|
return el_mkv_output_path
|
||||||
|
|
||||||
|
|
||||||
|
def handle_fel_detection(
|
||||||
|
el_type: str,
|
||||||
|
prompt: bool,
|
||||||
|
create_fel_mkv: bool,
|
||||||
|
file_input: Path,
|
||||||
|
working_dir: Path,
|
||||||
|
ffmpeg: Path,
|
||||||
|
dovi_tool: Path,
|
||||||
|
) -> None:
|
||||||
|
if el_type != "FEL" and create_fel_mkv:
|
||||||
|
exit_print(
|
||||||
|
"You have loaded a Dolby Vision source file that does NOT have a Full "
|
||||||
|
"Enhancement Layer (FEL). You must load a standard template to continue "
|
||||||
|
"processing this file.",
|
||||||
|
1,
|
||||||
|
)
|
||||||
|
if el_type == "FEL":
|
||||||
|
if prompt:
|
||||||
|
exit_print(
|
||||||
|
"You have loaded a Dolby Vision source file with a Full Enhancement "
|
||||||
|
"Layer (FEL). You must load a FEL-enabled template to continue "
|
||||||
|
"processing this file.",
|
||||||
|
1,
|
||||||
|
)
|
||||||
|
if create_fel_mkv:
|
||||||
|
created_fel = create_fel(file_input, working_dir, ffmpeg, dovi_tool)
|
||||||
|
exit_print(f"FEL layer: {created_fel}", 0)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
file_input, ffmpeg, dovi_tool, prompt, create_fel_mkv, working_dir = (
|
file_input, ffmpeg, dovi_tool, prompt, create_fel_mkv, working_dir = (
|
||||||
parse_arguments()
|
parse_arguments()
|
||||||
@ -253,54 +282,29 @@ if __name__ == "__main__":
|
|||||||
if existing_data:
|
if existing_data:
|
||||||
el_type = existing_data.get("EL")
|
el_type = existing_data.get("EL")
|
||||||
if el_type:
|
if el_type:
|
||||||
if el_type != "FEL" and create_fel_mkv:
|
|
||||||
exit_print(
|
|
||||||
"You have loaded a Dolby Vision source file that does NOT have a Full "
|
|
||||||
"Enhancement Layer (FEL). You must load a standard template to continue "
|
|
||||||
"processing this file.",
|
|
||||||
1,
|
|
||||||
)
|
|
||||||
print(f"Data loaded, EL type: {el_type}")
|
print(f"Data loaded, EL type: {el_type}")
|
||||||
if el_type == "FEL":
|
handle_fel_detection(
|
||||||
if prompt:
|
el_type,
|
||||||
exit_print(
|
prompt,
|
||||||
"You have loaded a Dolby Vision source file with a Full Enhancement "
|
create_fel_mkv,
|
||||||
"Layer (FEL). You must load a FEL-enabled template to continue "
|
file_input,
|
||||||
"processing this file.",
|
working_dir,
|
||||||
1,
|
ffmpeg,
|
||||||
)
|
dovi_tool,
|
||||||
if create_fel_mkv:
|
)
|
||||||
created_fel = create_fel(
|
|
||||||
file_input, working_dir, ffmpeg, dovi_tool
|
|
||||||
)
|
|
||||||
exit_print(f"FEL layer: {created_fel}", 0)
|
|
||||||
else:
|
else:
|
||||||
rpu = read_rpu(file_input, ffmpeg, dovi_tool, working_dir)
|
rpu = read_rpu(file_input, ffmpeg, dovi_tool, working_dir)
|
||||||
if rpu:
|
if rpu:
|
||||||
if rpu != "FEL" and create_fel_mkv:
|
handle_fel_detection(
|
||||||
exit_print(
|
rpu,
|
||||||
"You have loaded a Dolby Vision source file that does NOT have a Full "
|
prompt,
|
||||||
"Enhancement Layer (FEL). You must load a standard template to continue "
|
create_fel_mkv,
|
||||||
"processing this file.",
|
file_input,
|
||||||
1,
|
working_dir,
|
||||||
)
|
ffmpeg,
|
||||||
if rpu == "MEL":
|
dovi_tool,
|
||||||
exit_print("EL layer is MEL, no processing needed", 0)
|
)
|
||||||
elif rpu == "FEL":
|
|
||||||
if prompt:
|
|
||||||
exit_print(
|
|
||||||
"You have loaded a Dolby Vision source file with a Full Enhancement "
|
|
||||||
"Layer (FEL). You must load a FEL-enabled template to continue "
|
|
||||||
"processing this file.",
|
|
||||||
1,
|
|
||||||
)
|
|
||||||
if create_fel_mkv:
|
|
||||||
created_fel = create_fel(
|
|
||||||
file_input, working_dir, ffmpeg, dovi_tool
|
|
||||||
)
|
|
||||||
exit_print(f"FEL layer: {created_fel}", 0)
|
|
||||||
else:
|
else:
|
||||||
exit_print("No RPU data extracted", 1)
|
exit_print("No RPU data extracted", 1)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
exit_print("No EL layer detected", 0)
|
exit_print("No EL layer detected", 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user