Skip to content

fix: broken aspect ratio from target resolution rounding error #135

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

Merged
merged 4 commits into from
May 31, 2022
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
34 changes: 19 additions & 15 deletions resolve_proxy_encoder/worker/tasks/encode/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,25 @@ def encode_proxy(self, job):
)
logger.info(f"Output File: '{output_file}'\n")

# Get Resolution
# Get Resolutions
source_res = [int(x) for x in job["resolution"]]
v_res = int(proxy_settings["vertical_res"])
logger.info(f"Source Resolution: {source_res}")

v_res = int(proxy_settings["vertical_res"])
res_scale = int(source_res[1] / v_res)
h_res = int(source_res[0] / res_scale)
logger.info(f"Output Resolution: {[h_res, v_res]}")
def get_flip():

flip = str()
logger.info(
f"Horizontal Flip: {job['h_flip']}\n" f"Vertical Flip: {job['h_flip']}"
)

# Get Orientation
flip = str()
logger.info(f"Horizontal Flip: {job['h_flip']}\n" f"Vertical Flip: {job['h_flip']}")
if job["h_flip"]:
flip += " hflip, "

if job["h_flip"]:
flip += " hflip, "
if job["v_flip"]:
flip += "vflip, "

if job["v_flip"]:
flip += "vflip, "
return flip

# Log Timecode
logger.info(f"Starting Timecode: {job['start_tc']}")
Expand All @@ -111,7 +112,7 @@ def encode_proxy(self, job):
"-vsync",
"-1", # Necessary to match VFR
"-vf",
f"scale={h_res}:{v_res},{flip} format={proxy_settings['pix_fmt']}",
f"scale=-2:{v_res},{get_flip()} format={proxy_settings['pix_fmt']}",
"-c:a",
proxy_settings["audio_codec"],
"-ar",
Expand All @@ -132,9 +133,12 @@ def encode_proxy(self, job):
encode_log_dir = path_settings["ffmpeg_logfile_path"]
os.makedirs(encode_log_dir, exist_ok=True)

encode_log_file = os.path.join(
encode_log_dir, os.path.splitext(os.path.basename(output_file))[0] + ".txt"
encode_log_file = os.path.normpath(
os.path.join(
encode_log_dir, os.path.splitext(os.path.basename(output_file))[0] + ".txt"
)
)

logger.debug(f"[magenta]Encoder logfile path: {encode_log_file}[/]")

# Run encode job
Expand Down