비디오 영상 생성 요청시, 가사 전달 하는 항목 삭제, task_id로 직접 검색
This commit is contained in:
1 parent
47da24a12e
commit
c6a2fa6808
2 files changed
+23
-19
No files matched your search
@@ -55,11 +55,11 @@ Creatomate API를 통해 영상 생성을 요청합니다.
|
||||
## 요청 필드
|
||||
- **orientation**: 영상 방향 (horizontal: 가로형, vertical: 세로형, 기본값: vertical) - 선택
|
||||
- **image_urls**: 영상에 사용할 이미지 URL 목록 (필수)
|
||||
- **lyrics**: 영상에 표시할 가사 (필수)
|
||||
|
||||
## 자동 조회 정보
|
||||
- **music_url**: Song 테이블에서 task_id 기준 가장 최근 생성된 노래의 song_result_url 사용
|
||||
- **duration**: Song 테이블에서 task_id 기준 가장 최근 생성된 노래의 duration 사용
|
||||
## 자동 조회 정보 (Song 테이블에서 task_id 기준 가장 최근 생성된 노래 사용)
|
||||
- **music_url**: song_result_url 사용
|
||||
- **duration**: 노래의 duration 사용
|
||||
- **lyrics**: song_prompt (가사) 사용
|
||||
|
||||
## 반환 정보
|
||||
- **success**: 요청 성공 여부
|
||||
@@ -82,8 +82,7 @@ POST /video/generate/019123ab-cdef-7890-abcd-ef1234567890
|
||||
"https://naverbooking-phinf.pstatic.net/20240514_192/1715688031798MbFDj_JPEG/8.jpg",
|
||||
"https://naverbooking-phinf.pstatic.net/20240514_205/17156880318681JLwX_JPEG/9.jpg",
|
||||
"https://naverbooking-phinf.pstatic.net/20240514_142/1715688031946hhxHz_JPEG/10.jpg"
|
||||
],
|
||||
"lyrics": "가사 내용..."
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
@@ -92,22 +91,21 @@ POST /video/generate/019123ab-cdef-7890-abcd-ef1234567890
|
||||
POST /video/generate/019123ab-cdef-7890-abcd-ef1234567890
|
||||
{
|
||||
"orientation": "horizontal",
|
||||
"image_urls": [...],
|
||||
"lyrics": "가사 내용..."
|
||||
"image_urls": [...]
|
||||
}
|
||||
```
|
||||
|
||||
## 참고
|
||||
- 배경 음악(music_url)과 영상 길이(duration)는 task_id로 Song 테이블을 조회하여 자동으로 가져옵니다.
|
||||
- 배경 음악(music_url), 영상 길이(duration), 가사(lyrics)는 task_id로 Song 테이블을 조회하여 자동으로 가져옵니다.
|
||||
- 같은 task_id로 여러 Song이 있을 경우 **가장 최근 생성된 노래**를 사용합니다.
|
||||
- Song의 status가 completed이고 song_result_url이 있어야 영상 생성이 가능합니다.
|
||||
- Song의 song_result_url과 song_prompt가 있어야 영상 생성이 가능합니다.
|
||||
- creatomate_render_id를 사용하여 /status/{creatomate_render_id} 엔드포인트에서 생성 상태를 확인할 수 있습니다.
|
||||
- Video 테이블에 데이터가 저장되며, project_id, lyric_id, song_id가 자동으로 연결됩니다.
|
||||
""",
|
||||
response_model=GenerateVideoResponse,
|
||||
responses={
|
||||
200: {"description": "영상 생성 요청 성공"},
|
||||
400: {"description": "Song의 음악 URL이 없음 (노래 생성 미완료)"},
|
||||
400: {"description": "Song의 음악 URL 또는 가사(song_prompt)가 없음"},
|
||||
404: {"description": "Project, Lyric 또는 Song을 찾을 수 없음"},
|
||||
500: {"description": "영상 생성 요청 실패"},
|
||||
},
|
||||
@@ -179,8 +177,17 @@ async def generate_video(
|
||||
detail=f"Song(id={song.id})의 음악 URL이 없습니다. 노래 생성이 완료되었는지 확인하세요.",
|
||||
)
|
||||
|
||||
# Song에서 가사(song_prompt) 가져오기
|
||||
lyrics = song.song_prompt
|
||||
if not lyrics:
|
||||
print(f"[generate_video] Song has no lyrics (song_prompt) - task_id: {task_id}, song_id: {song.id}")
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail=f"Song(id={song.id})의 가사(song_prompt)가 없습니다.",
|
||||
)
|
||||
|
||||
print(f"[generate_video] Song found - song_id: {song.id}, task_id: {task_id}, duration: {song.duration}")
|
||||
print(f"[generate_video] Music URL (from DB): {music_url}, Song duration: {song.duration}")
|
||||
print(f"[generate_video] Music URL (from DB): {music_url}, Song duration: {song.duration}, Lyrics length: {len(lyrics)}")
|
||||
|
||||
# 4. Video 테이블에 초기 데이터 저장
|
||||
video = Video(
|
||||
@@ -208,11 +215,11 @@ async def generate_video(
|
||||
template = await creatomate_service.get_one_template_data_async(creatomate_service.template_id)
|
||||
print(f"[generate_video] Template fetched - task_id: {task_id}")
|
||||
|
||||
# 5-2. elements에서 리소스 매핑 생성 (music_url은 DB에서 조회한 값 사용)
|
||||
# 5-2. elements에서 리소스 매핑 생성 (music_url, lyrics는 DB에서 조회한 값 사용)
|
||||
modifications = creatomate_service.elements_connect_resource_blackbox(
|
||||
elements=template["source"]["elements"],
|
||||
image_url_list=request_body.image_urls,
|
||||
lyric=request_body.lyrics,
|
||||
lyric=lyrics,
|
||||
music_url=music_url,
|
||||
)
|
||||
print(f"[generate_video] Modifications created - task_id: {task_id}")
|
||||
|
||||
Reference in new issue
Block a user