feat: Persist regenerated image/audio paths to storyboard.json
This commit is contained in:
@@ -514,6 +514,27 @@ async def regenerate_frame_image(
|
|||||||
target_frame["image_path"] = _path_to_url(image_path)
|
target_frame["image_path"] = _path_to_url(image_path)
|
||||||
_storyboard_cache[storyboard_id] = storyboard
|
_storyboard_cache[storyboard_id] = storyboard
|
||||||
|
|
||||||
|
# Persist changes to storyboard.json
|
||||||
|
try:
|
||||||
|
from pixelle_video.services.persistence import PersistenceService
|
||||||
|
persistence = PersistenceService()
|
||||||
|
|
||||||
|
# Load existing storyboard model
|
||||||
|
storyboard_model = await persistence.load_storyboard(storyboard_id)
|
||||||
|
if storyboard_model:
|
||||||
|
# Update the specific frame's image_path
|
||||||
|
for frame in storyboard_model.frames:
|
||||||
|
if f"frame-{frame.index}" == frame_id:
|
||||||
|
frame.image_path = image_path
|
||||||
|
logger.debug(f"[PERSIST] Updated frame {frame_id} image_path in model")
|
||||||
|
break
|
||||||
|
|
||||||
|
# Save back to JSON
|
||||||
|
await persistence.save_storyboard(storyboard_id, storyboard_model)
|
||||||
|
logger.info(f"[PERSIST] Saved storyboard to JSON for {storyboard_id}")
|
||||||
|
except Exception as pe:
|
||||||
|
logger.warning(f"[PERSIST] Failed to persist storyboard: {pe}")
|
||||||
|
|
||||||
logger.info(f"Regenerated image for frame {frame_id} via RunningHub")
|
logger.info(f"Regenerated image for frame {frame_id} via RunningHub")
|
||||||
|
|
||||||
return RegenerateImageResponse(
|
return RegenerateImageResponse(
|
||||||
@@ -605,6 +626,31 @@ async def regenerate_frame_audio(
|
|||||||
storyboard["total_duration"] = sum(f.get("duration", 3.0) for f in frames)
|
storyboard["total_duration"] = sum(f.get("duration", 3.0) for f in frames)
|
||||||
_storyboard_cache[storyboard_id] = storyboard
|
_storyboard_cache[storyboard_id] = storyboard
|
||||||
|
|
||||||
|
# Persist changes to storyboard.json
|
||||||
|
try:
|
||||||
|
from pixelle_video.services.persistence import PersistenceService
|
||||||
|
persistence = PersistenceService()
|
||||||
|
|
||||||
|
# Load existing storyboard model
|
||||||
|
storyboard_model = await persistence.load_storyboard(storyboard_id)
|
||||||
|
if storyboard_model:
|
||||||
|
# Update the specific frame's audio_path and duration
|
||||||
|
for frame in storyboard_model.frames:
|
||||||
|
if f"frame-{frame.index}" == frame_id:
|
||||||
|
frame.audio_path = result_path
|
||||||
|
frame.duration = duration
|
||||||
|
logger.debug(f"[PERSIST] Updated frame {frame_id} audio_path in model")
|
||||||
|
break
|
||||||
|
|
||||||
|
# Update total duration
|
||||||
|
storyboard_model.total_duration = sum(f.duration or 3.0 for f in storyboard_model.frames)
|
||||||
|
|
||||||
|
# Save back to JSON
|
||||||
|
await persistence.save_storyboard(storyboard_id, storyboard_model)
|
||||||
|
logger.info(f"[PERSIST] Saved storyboard to JSON for {storyboard_id}")
|
||||||
|
except Exception as pe:
|
||||||
|
logger.warning(f"[PERSIST] Failed to persist storyboard: {pe}")
|
||||||
|
|
||||||
logger.info(f"Regenerated audio for frame {frame_id}, duration: {duration}s")
|
logger.info(f"Regenerated audio for frame {frame_id}, duration: {duration}s")
|
||||||
|
|
||||||
return RegenerateAudioResponse(
|
return RegenerateAudioResponse(
|
||||||
|
|||||||
Reference in New Issue
Block a user