비디오 영상 생성 요청 버그 픽스
parent
d4bce083ab
commit
47da24a12e
|
|
@ -56,7 +56,10 @@ Creatomate API를 통해 영상 생성을 요청합니다.
|
||||||
- **orientation**: 영상 방향 (horizontal: 가로형, vertical: 세로형, 기본값: vertical) - 선택
|
- **orientation**: 영상 방향 (horizontal: 가로형, vertical: 세로형, 기본값: vertical) - 선택
|
||||||
- **image_urls**: 영상에 사용할 이미지 URL 목록 (필수)
|
- **image_urls**: 영상에 사용할 이미지 URL 목록 (필수)
|
||||||
- **lyrics**: 영상에 표시할 가사 (필수)
|
- **lyrics**: 영상에 표시할 가사 (필수)
|
||||||
- **music_url**: 배경 음악 URL (필수)
|
|
||||||
|
## 자동 조회 정보
|
||||||
|
- **music_url**: Song 테이블에서 task_id 기준 가장 최근 생성된 노래의 song_result_url 사용
|
||||||
|
- **duration**: Song 테이블에서 task_id 기준 가장 최근 생성된 노래의 duration 사용
|
||||||
|
|
||||||
## 반환 정보
|
## 반환 정보
|
||||||
- **success**: 요청 성공 여부
|
- **success**: 요청 성공 여부
|
||||||
|
|
@ -80,8 +83,7 @@ POST /video/generate/019123ab-cdef-7890-abcd-ef1234567890
|
||||||
"https://naverbooking-phinf.pstatic.net/20240514_205/17156880318681JLwX_JPEG/9.jpg",
|
"https://naverbooking-phinf.pstatic.net/20240514_205/17156880318681JLwX_JPEG/9.jpg",
|
||||||
"https://naverbooking-phinf.pstatic.net/20240514_142/1715688031946hhxHz_JPEG/10.jpg"
|
"https://naverbooking-phinf.pstatic.net/20240514_142/1715688031946hhxHz_JPEG/10.jpg"
|
||||||
],
|
],
|
||||||
"lyrics": "가사 내용...",
|
"lyrics": "가사 내용..."
|
||||||
"music_url": "https://ado2mediastoragepublic.blob.core.windows.net/ado2-media-public-access/ado2-media-original/0694e2d8-7ae2-730c-8000-308aacaa582d/song/스테이 머뭄.mp3"
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -91,18 +93,21 @@ POST /video/generate/019123ab-cdef-7890-abcd-ef1234567890
|
||||||
{
|
{
|
||||||
"orientation": "horizontal",
|
"orientation": "horizontal",
|
||||||
"image_urls": [...],
|
"image_urls": [...],
|
||||||
"lyrics": "가사 내용...",
|
"lyrics": "가사 내용..."
|
||||||
"music_url": "https://..."
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## 참고
|
## 참고
|
||||||
|
- 배경 음악(music_url)과 영상 길이(duration)는 task_id로 Song 테이블을 조회하여 자동으로 가져옵니다.
|
||||||
|
- 같은 task_id로 여러 Song이 있을 경우 **가장 최근 생성된 노래**를 사용합니다.
|
||||||
|
- Song의 status가 completed이고 song_result_url이 있어야 영상 생성이 가능합니다.
|
||||||
- creatomate_render_id를 사용하여 /status/{creatomate_render_id} 엔드포인트에서 생성 상태를 확인할 수 있습니다.
|
- creatomate_render_id를 사용하여 /status/{creatomate_render_id} 엔드포인트에서 생성 상태를 확인할 수 있습니다.
|
||||||
- Video 테이블에 데이터가 저장되며, project_id, lyric_id, song_id가 자동으로 연결됩니다.
|
- Video 테이블에 데이터가 저장되며, project_id, lyric_id, song_id가 자동으로 연결됩니다.
|
||||||
""",
|
""",
|
||||||
response_model=GenerateVideoResponse,
|
response_model=GenerateVideoResponse,
|
||||||
responses={
|
responses={
|
||||||
200: {"description": "영상 생성 요청 성공"},
|
200: {"description": "영상 생성 요청 성공"},
|
||||||
|
400: {"description": "Song의 음악 URL이 없음 (노래 생성 미완료)"},
|
||||||
404: {"description": "Project, Lyric 또는 Song을 찾을 수 없음"},
|
404: {"description": "Project, Lyric 또는 Song을 찾을 수 없음"},
|
||||||
500: {"description": "영상 생성 요청 실패"},
|
500: {"description": "영상 생성 요청 실패"},
|
||||||
},
|
},
|
||||||
|
|
@ -164,8 +169,18 @@ async def generate_video(
|
||||||
status_code=404,
|
status_code=404,
|
||||||
detail=f"task_id '{task_id}'에 해당하는 Song을 찾을 수 없습니다.",
|
detail=f"task_id '{task_id}'에 해당하는 Song을 찾을 수 없습니다.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Song에서 music_url과 duration 가져오기
|
||||||
|
music_url = song.song_result_url
|
||||||
|
if not music_url:
|
||||||
|
print(f"[generate_video] Song has no result URL - task_id: {task_id}, song_id: {song.id}")
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=400,
|
||||||
|
detail=f"Song(id={song.id})의 음악 URL이 없습니다. 노래 생성이 완료되었는지 확인하세요.",
|
||||||
|
)
|
||||||
|
|
||||||
print(f"[generate_video] Song found - song_id: {song.id}, task_id: {task_id}, duration: {song.duration}")
|
print(f"[generate_video] Song found - song_id: {song.id}, task_id: {task_id}, duration: {song.duration}")
|
||||||
print(f"[generate_video] Music URL: {request_body.music_url}, Song duration: {song.duration}")
|
print(f"[generate_video] Music URL (from DB): {music_url}, Song duration: {song.duration}")
|
||||||
|
|
||||||
# 4. Video 테이블에 초기 데이터 저장
|
# 4. Video 테이블에 초기 데이터 저장
|
||||||
video = Video(
|
video = Video(
|
||||||
|
|
@ -193,12 +208,12 @@ async def generate_video(
|
||||||
template = await creatomate_service.get_one_template_data_async(creatomate_service.template_id)
|
template = await creatomate_service.get_one_template_data_async(creatomate_service.template_id)
|
||||||
print(f"[generate_video] Template fetched - task_id: {task_id}")
|
print(f"[generate_video] Template fetched - task_id: {task_id}")
|
||||||
|
|
||||||
# 5-2. elements에서 리소스 매핑 생성
|
# 5-2. elements에서 리소스 매핑 생성 (music_url은 DB에서 조회한 값 사용)
|
||||||
modifications = creatomate_service.elements_connect_resource_blackbox(
|
modifications = creatomate_service.elements_connect_resource_blackbox(
|
||||||
elements=template["source"]["elements"],
|
elements=template["source"]["elements"],
|
||||||
image_url_list=request_body.image_urls,
|
image_url_list=request_body.image_urls,
|
||||||
lyric=request_body.lyrics,
|
lyric=request_body.lyrics,
|
||||||
music_url=request_body.music_url,
|
music_url=music_url,
|
||||||
)
|
)
|
||||||
print(f"[generate_video] Modifications created - task_id: {task_id}")
|
print(f"[generate_video] Modifications created - task_id: {task_id}")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,15 @@ class GenerateVideoRequest(BaseModel):
|
||||||
POST /video/generate/{task_id}
|
POST /video/generate/{task_id}
|
||||||
Request body for generating a video via Creatomate API.
|
Request body for generating a video via Creatomate API.
|
||||||
|
|
||||||
|
Note:
|
||||||
|
- music_url과 duration은 task_id로 Song 테이블에서 자동 조회됩니다.
|
||||||
|
- 같은 task_id로 여러 Song이 있을 경우 가장 최근 생성된 것을 사용합니다.
|
||||||
|
|
||||||
Example Request:
|
Example Request:
|
||||||
{
|
{
|
||||||
"template_id": "abc123...",
|
"orientation": "vertical",
|
||||||
"image_urls": ["https://...", "https://..."],
|
"image_urls": ["https://...", "https://..."],
|
||||||
"lyrics": "가사 내용...",
|
"lyrics": "가사 내용..."
|
||||||
"music_url": "https://..."
|
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -48,7 +51,6 @@ class GenerateVideoRequest(BaseModel):
|
||||||
"https://naverbooking-phinf.pstatic.net/20240514_142/1715688031946hhxHz_JPEG/10.jpg",
|
"https://naverbooking-phinf.pstatic.net/20240514_142/1715688031946hhxHz_JPEG/10.jpg",
|
||||||
],
|
],
|
||||||
"lyrics": "인스타 감성의 스테이 머뭄, 머물러봐요\n군산 신흥동 말랭이 마을의 마음 힐링",
|
"lyrics": "인스타 감성의 스테이 머뭄, 머물러봐요\n군산 신흥동 말랭이 마을의 마음 힐링",
|
||||||
"music_url": "https://ado2mediastoragepublic.blob.core.windows.net/ado2-media-public-access/ado2-media-original/0694e2d8-7ae2-730c-8000-308aacaa582d/song/스테이 머뭄.mp3",
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -59,7 +61,6 @@ class GenerateVideoRequest(BaseModel):
|
||||||
)
|
)
|
||||||
image_urls: List[str] = Field(..., description="영상에 사용할 이미지 URL 목록")
|
image_urls: List[str] = Field(..., description="영상에 사용할 이미지 URL 목록")
|
||||||
lyrics: str = Field(..., description="영상에 표시할 가사")
|
lyrics: str = Field(..., description="영상에 표시할 가사")
|
||||||
music_url: str = Field(..., description="배경 음악 URL")
|
|
||||||
|
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue