update and make test for transcribe and chat_vod and shorts
This commit is contained in:
+22
-12
@@ -11,7 +11,7 @@ def combine_twitch_vod_and_chat(vod_path: str, layout: str = "side-by-side") ->
|
||||
chat_path = video_path.replace(".mp4", "_chat.json")
|
||||
temp_chat = video_path.replace(".mp4", "_temp_chat.mp4")
|
||||
video_chat = video_path.replace(".mp4", "_with_chat.mp4")
|
||||
mask_path = video_chat.replace(".mp4", "_mask.mp4")
|
||||
mask_path = video_path.replace(".mp4", "_temp_chat_mask.mp4")
|
||||
|
||||
# Step 1: Pre-flight checks
|
||||
if not os.path.exists(video_path):
|
||||
@@ -33,16 +33,21 @@ def combine_twitch_vod_and_chat(vod_path: str, layout: str = "side-by-side") ->
|
||||
f"-w 400 -h 1080 "
|
||||
f"--collision Overwrite "
|
||||
f"--temp-path download/temp "
|
||||
f"--font-size 25 "
|
||||
f"--font-size 20 "
|
||||
f"--generate-mask "
|
||||
f"-o {temp_chat}"
|
||||
f'--output-args="-threads 8 "'
|
||||
f"--background-color #00000000 "
|
||||
f"-o {temp_chat} "
|
||||
)
|
||||
|
||||
chat_success = linux.run_command(chat_cmd, progress_prefix="Chat Render")
|
||||
if not chat_success:
|
||||
print("❌ Error: TwitchDownloaderCLI failed to render chat video.")
|
||||
return False
|
||||
|
||||
if not os.path.exists(temp_chat):
|
||||
chat_success = linux.run_command(chat_cmd, look_for=["[STATUS]"])
|
||||
if chat_success:
|
||||
print("✅ Success: TwitchDownloaderCLI render chat video.")
|
||||
else:
|
||||
print(f"❌ Error: TwitchDownloaderCLI failed to render chat video. {chat_success['error']} : {chat_success['stderr']}")
|
||||
os.remove(temp_chat)
|
||||
os.remove(mask_path)
|
||||
return False
|
||||
|
||||
# Step 3: Combine Video and Chat using FFmpeg
|
||||
print("====================================================")
|
||||
@@ -67,7 +72,7 @@ def combine_twitch_vod_and_chat(vod_path: str, layout: str = "side-by-side") ->
|
||||
else:
|
||||
raise ValueError("Invalid layout choice. Choose 'side-by-side' or 'overlay'.")
|
||||
|
||||
ffmpeg_success = linux.run_command_ffmpeg(ffmpeg_cmd, progress_prefix="FFmpeg Merge")
|
||||
ffmpeg_success = linux.run_command(ffmpeg_cmd, progress_prefix="FFmpeg Merge")
|
||||
|
||||
# Step 4: Final verification and cleanup
|
||||
if ffmpeg_success and os.path.exists(video_chat):
|
||||
@@ -79,8 +84,13 @@ def combine_twitch_vod_and_chat(vod_path: str, layout: str = "side-by-side") ->
|
||||
# Clean up the massive temporary chat video to save storage space
|
||||
if os.path.exists(temp_chat):
|
||||
print("🧹 Cleaning up temporary chat render video...")
|
||||
#os.remove(temp_chat)
|
||||
os.remove(temp_chat)
|
||||
os.remove(mask_path)
|
||||
return True
|
||||
else:
|
||||
print("❌ Error: FFmpeg failed to merge the video streams.")
|
||||
return False
|
||||
os.remove(video_chat)
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
combine_twitch_vod_and_chat("download/videos/2813112936/2813112936.mp4", "overlay")
|
||||
Reference in New Issue
Block a user