Add support for merging video and chat with configurable layout options

This commit is contained in:
MaddoScientisto 2026-02-10 00:06:49 +01:00
commit 832bf4cf36
6 changed files with 199 additions and 10 deletions

View file

@ -136,6 +136,17 @@ class ContentDownloader:
print(f'{Fore.RED}✗ Chat JSON file not found: {json_path}{Style.RESET_ALL}')
return False
# Validate JSON file has content (check if file size is reasonable)
try:
file_size = os.path.getsize(json_path)
if file_size < 100: # Less than 100 bytes means likely empty or invalid
print(f'{Fore.RED}✗ Chat JSON file is too small or incomplete ({file_size} bytes){Style.RESET_ALL}')
print(f'{Fore.YELLOW} This can happen when stream recording is interrupted{Style.RESET_ALL}')
return False
except Exception as e:
print(f'{Fore.RED}✗ Error checking chat JSON file: {str(e)}{Style.RESET_ALL}')
return False
bin_path = get_bin_path()
# Chat rendering settings
@ -148,19 +159,20 @@ class ContentDownloader:
'--font-size', '22',
'--update-rate', '1.0',
'--offline',
'--output-args', output_args,
'--ffmpeg-path', self.ffmpeg_path,
'--temp-path', os.path.join(bin_path, 'temp'),
'--collision', 'Rename'
]
# Add output args using = syntax to avoid parsing issues
if output_args:
chat_settings.append(f'--output-args={output_args}')
try:
print(f'{Fore.YELLOW}Rendering chat video...{Style.RESET_ALL}')
# Debug output
# Build complete command
full_cmd = [self.twitch_downloader_path, 'chatrender', '-i', json_path, '-o', video_path] + chat_settings
print(f'{Fore.CYAN}DEBUG - Chat render command:{Style.RESET_ALL}')
print(f'{Fore.CYAN} Output args passed: {repr(output_args)}{Style.RESET_ALL}')
result = subprocess.call(full_cmd)