Skip to content

Commit

Permalink
Add function to upscale video after file creation
Browse files Browse the repository at this point in the history
The upscale function was moved from the process of creating left and right-eye files into a separate function called `create_upscaled_file`. This function is now executed after the left and right-eye files are combined into a `mv_hevc_file`. The `UPSCALE_VIDEO` stage was also moved in the configurations. This rearrangement allows for cleaner code organization and maintains proper sequencing of video processing stages.
  • Loading branch information
cbusillo committed Jun 20, 2024
1 parent 59ad87c commit 4e62ad6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bd_to_avp/modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class Stage(Enum):
CREATE_MKV = auto()
EXTRACT_MVC_AUDIO_AND_SUB = auto()
CREATE_LEFT_RIGHT_FILES = auto()
UPSCALE_VIDEO = auto()
COMBINE_TO_MV_HEVC = auto()
UPSCALE_VIDEO = auto()
TRANSCODE_AUDIO = auto()
CREATE_FINAL_FILE = auto()
MOVE_FILES = auto()
Expand Down
10 changes: 8 additions & 2 deletions bd_to_avp/modules/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
prepare_output_folder_for_source,
remove_folder_if_exists,
)
from bd_to_avp.modules.video import create_left_right_files, create_mv_hevc_file, detect_crop_parameters
from bd_to_avp.modules.video import (
create_left_right_files,
create_mv_hevc_file,
detect_crop_parameters,
create_upscaled_file,
)


def process() -> None:
Expand Down Expand Up @@ -64,8 +69,9 @@ def process_each() -> None:
disc_info, output_folder, video_output_path, crop_params
)
mv_hevc_path = create_mv_hevc_file(left_output_path, right_output_path, output_folder, disc_info.name)
audio_output_path = create_transcoded_audio_file(audio_output_path, output_folder)
mv_hevc_path = create_upscaled_file(mv_hevc_path)

audio_output_path = create_transcoded_audio_file(audio_output_path, output_folder)
muxed_output_path = create_muxed_file(
audio_output_path,
mv_hevc_path,
Expand Down
16 changes: 9 additions & 7 deletions bd_to_avp/modules/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,6 @@ def create_left_right_files(
crop_params,
)

if config.fx_upscale:
if config.start_stage.value <= Stage.UPSCALE_VIDEO.value:
upscale_file(left_eye_output_path)
upscale_file(right_eye_output_path)
left_eye_output_path = left_eye_output_path.with_stem(f"{left_eye_output_path.stem} Upscaled")
right_eye_output_path = right_eye_output_path.with_stem(f"{right_eye_output_path.stem} Upscaled")

return left_eye_output_path, right_eye_output_path


Expand All @@ -237,3 +230,12 @@ def create_mv_hevc_file(left_video_path: Path, right_video_path: Path, output_fo
left_video_path.unlink(missing_ok=True)
right_video_path.unlink(missing_ok=True)
return mv_hevc_path


def create_upscaled_file(input_path: Path) -> Path:
if config.fx_upscale:
if config.start_stage.value <= Stage.UPSCALE_VIDEO.value:
upscale_file(input_path)

return input_path.with_stem(f"{input_path.stem} Upscaled")
return input_path

0 comments on commit 4e62ad6

Please sign in to comment.