fixed nvenc check and refactored

pull/2259/head
LevaniVashadze 6 months ago
parent f1f67a0272
commit fb94c432e9

@ -84,9 +84,10 @@ def name_normalize(name: str) -> str:
return name return name
def check_nvenc_support(): def get_encoder():
"""Check if the system supports NVENC encoding by attempting to encode a test frame.""" """Check if the system supports NVENC encoding by attempting to encode a test frame."""
import subprocess import subprocess
base_encoder = "libx264"
try: try:
# Try to encode a single black frame using NVENC # Try to encode a single black frame using NVENC
@ -100,9 +101,16 @@ def check_nvenc_support():
) )
# If the command succeeds (return code 0) and there's no error output, NVENC is supported # If the command succeeds (return code 0) and there's no error output, NVENC is supported
return result.returncode == 0 and not result.stderr if result.returncode == 0:
except Exception: print("NVENC supported")
return False return "h264_nvenc"
else:
print("NVENC not supported")
return base_encoder
except Exception as e:
print(f"Error while checking for NVENC support: {e}")
print("Falling back to libx264")
return base_encoder
@ -240,11 +248,7 @@ def make_final_video(
reddit_id = extract_id(reddit_obj) reddit_id = extract_id(reddit_obj)
if check_nvenc_support(): encoder = get_encoder()
print("Using NVENC Encoder.")
encoder = "h264_nvenc"
else:
encoder = "libx264"
allowOnlyTTSFolder: bool = ( allowOnlyTTSFolder: bool = (
settings.config["settings"]["background"]["enable_extra_audio"] settings.config["settings"]["background"]["enable_extra_audio"]

Loading…
Cancel
Save