mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-20 13:07:57 +09:00
fix: video worker downloads PNG instead of MOV for screens (#650)
## Summary Follow-up to #647. The video worker was hardcoded to download `title.mov`/`end.mov` from GCS, but those no longer exist after the screens_worker change. 404 error on all job retries. - `video_worker.py`: download PNG (or MOV for legacy), validate with PNG fallback - `video_worker_orchestrator.py`: `_screen_ext()` helper for dynamic file extension ## Test plan - [x] All video unit tests pass - [ ] Retry job f0d51a0a after deploy @coderabbitai ignore 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
ead074505b
commit
fbe3edceec
4 files changed
+46
-20
No files matched your search
@@ -1256,6 +1256,7 @@ class TestCreateOrchestratorConfigFromJob:
|
||||
job.gdrive_folder_id = None
|
||||
job.keep_brand_code = None
|
||||
job.existing_instrumental_gcs_path = None
|
||||
job.file_urls = {'screens': {'title_png': 'jobs/test-123/screens/title.png', 'end_png': 'jobs/test-123/screens/end.png'}}
|
||||
|
||||
config = create_orchestrator_config_from_job(
|
||||
job=job,
|
||||
@@ -1269,7 +1270,7 @@ class TestCreateOrchestratorConfigFromJob:
|
||||
assert config.title == "Test Title"
|
||||
assert config.enable_cdg is True
|
||||
assert config.enable_youtube_upload is True
|
||||
assert config.title_video_path == "/tmp/test/Test Artist - Test Title (Title).mov"
|
||||
assert config.title_video_path == "/tmp/test/Test Artist - Test Title (Title).png"
|
||||
assert config.instrumental_audio_path == "/tmp/test/Test Artist - Test Title (Instrumental Clean).flac"
|
||||
|
||||
def test_create_config_from_job_with_existing_instrumental(self):
|
||||
@@ -1290,6 +1291,7 @@ class TestCreateOrchestratorConfigFromJob:
|
||||
job.gdrive_folder_id = None
|
||||
job.keep_brand_code = None
|
||||
job.existing_instrumental_gcs_path = "gs://bucket/instrumental.mp3"
|
||||
job.file_urls = {'screens': {'title_png': 'screens/title.png', 'end_png': 'screens/end.png'}}
|
||||
|
||||
config = create_orchestrator_config_from_job(
|
||||
job=job,
|
||||
@@ -1329,6 +1331,7 @@ class TestCreateOrchestratorConfigFromJob:
|
||||
job.gdrive_folder_id = None
|
||||
job.keep_brand_code = None
|
||||
job.existing_instrumental_gcs_path = None
|
||||
job.file_urls = {'screens': {'title_png': 'screens/title.png', 'end_png': 'screens/end.png'}}
|
||||
|
||||
config = create_orchestrator_config_from_job(
|
||||
job=job,
|
||||
|
||||
@@ -1231,9 +1231,11 @@ def _validate_prerequisites(job) -> bool:
|
||||
logger.error(f"Job {job.job_id}: Invalid instrumental selection: {instrumental_selection}")
|
||||
return False
|
||||
|
||||
# Check screens exist
|
||||
# Check screens exist (MOV or PNG — MOV is no longer uploaded, PNG is the new default)
|
||||
screens = job.file_urls.get('screens', {})
|
||||
if not screens.get('title') or not screens.get('end'):
|
||||
has_title = screens.get('title') or screens.get('title_png')
|
||||
has_end = screens.get('end') or screens.get('end_png')
|
||||
if not has_title or not has_end:
|
||||
logger.error(f"Job {job.job_id}: Missing title or end screen")
|
||||
return False
|
||||
|
||||
@@ -1287,19 +1289,24 @@ async def _setup_working_directory(
|
||||
|
||||
log_progress("Setting up working directory")
|
||||
|
||||
# Download title screen
|
||||
log_progress("Downloading title screen...")
|
||||
title_url = job.file_urls['screens']['title']
|
||||
title_path = os.path.join(temp_dir, f"{base_name} (Title).mov")
|
||||
storage.download_file(title_url, title_path)
|
||||
log_progress("Downloaded title screen")
|
||||
|
||||
# Download end screen
|
||||
log_progress("Downloading end screen...")
|
||||
end_url = job.file_urls['screens']['end']
|
||||
end_path = os.path.join(temp_dir, f"{base_name} (End).mov")
|
||||
storage.download_file(end_url, end_path)
|
||||
log_progress("Downloaded end screen")
|
||||
# Download title screen (PNG — MOV video is generated by the GCE encoding worker)
|
||||
screens = job.file_urls.get('screens', {})
|
||||
title_url = screens.get('title') or screens.get('title_png')
|
||||
if title_url:
|
||||
ext = os.path.splitext(title_url)[1] or '.png'
|
||||
title_path = os.path.join(temp_dir, f"{base_name} (Title){ext}")
|
||||
log_progress(f"Downloading title screen ({ext})...")
|
||||
storage.download_file(title_url, title_path)
|
||||
log_progress("Downloaded title screen")
|
||||
|
||||
# Download end screen (PNG — MOV video is generated by the GCE encoding worker)
|
||||
end_url = screens.get('end') or screens.get('end_png')
|
||||
if end_url:
|
||||
ext = os.path.splitext(end_url)[1] or '.png'
|
||||
end_path = os.path.join(temp_dir, f"{base_name} (End){ext}")
|
||||
log_progress(f"Downloading end screen ({ext})...")
|
||||
storage.download_file(end_url, end_path)
|
||||
log_progress("Downloaded end screen")
|
||||
|
||||
# Download lyrics video (with vocals) - this is the largest file, ~1-2GB
|
||||
log_progress("Downloading karaoke video (largest file, may take 1-2 minutes)...")
|
||||
|
||||
@@ -836,6 +836,22 @@ class VideoWorkerOrchestrator:
|
||||
# Never fail the pipeline for validation
|
||||
|
||||
|
||||
def _screen_ext(job, screen_type: str) -> str:
|
||||
"""Get the file extension for a screen (title/end) based on what's in GCS.
|
||||
|
||||
New jobs have only PNG (MOV is generated by GCE encoding worker).
|
||||
Legacy jobs may still have MOV uploaded by the old screens_worker.
|
||||
"""
|
||||
screens = job.file_urls.get('screens', {})
|
||||
# Check for MOV first (legacy), then fall back to PNG (new)
|
||||
url = screens.get(screen_type) or screens.get(f'{screen_type}_png')
|
||||
if url:
|
||||
ext = os.path.splitext(url)[1]
|
||||
if ext:
|
||||
return ext
|
||||
return '.png'
|
||||
|
||||
|
||||
def create_orchestrator_config_from_job(
|
||||
job,
|
||||
temp_dir: str,
|
||||
@@ -893,12 +909,12 @@ def create_orchestrator_config_from_job(
|
||||
artist=job.artist,
|
||||
title=job.title,
|
||||
|
||||
# Input files
|
||||
title_video_path=os.path.join(temp_dir, f"{base_name} (Title).mov"),
|
||||
# Input files — use actual extension from GCS (PNG for new jobs, MOV for legacy)
|
||||
title_video_path=os.path.join(temp_dir, f"{base_name} (Title){_screen_ext(job, 'title')}"),
|
||||
# Use actual extension from GCS path (typically .mkv) instead of hardcoding .mov
|
||||
karaoke_video_path=os.path.join(temp_dir, f"{base_name} (With Vocals){os.path.splitext(job.file_urls.get('videos', {}).get('with_vocals', '.mkv'))[1] or '.mkv'}"),
|
||||
instrumental_audio_path=instrumental_path,
|
||||
end_video_path=os.path.join(temp_dir, f"{base_name} (End).mov"),
|
||||
end_video_path=os.path.join(temp_dir, f"{base_name} (End){_screen_ext(job, 'end')}"),
|
||||
lrc_file_path=os.path.join(temp_dir, f"{base_name} (Karaoke).lrc"),
|
||||
title_jpg_path=os.path.join(temp_dir, f"{base_name} (Title).jpg"),
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "karaoke-gen"
|
||||
version = "0.157.1"
|
||||
version = "0.157.2"
|
||||
description = "Generate karaoke videos with synchronized lyrics. Handles the entire process from downloading audio and lyrics to creating the final video with title screens."
|
||||
authors = ["Andrew Beveridge <andrew@beveridge.uk>"]
|
||||
license = "MIT"
|
||||
|
||||
Reference in new issue
Block a user