Compare commits

..

3 Commits

Author SHA1 Message Date
jaehwang e1386b891e Merge branch 'main' into creatomate 2026-02-02 07:58:19 +00:00
jaehwang f97ecb29e9 fix missing argument 2026-02-02 07:05:27 +00:00
jaehwang 5700965fae 비디오 automated lyric 가사 (animated)추가 2026-02-02 14:17:01 +09:00
3 changed files with 77 additions and 13 deletions

View File

@ -147,6 +147,49 @@ text_template_h_1 = {
] ]
} }
autotext_template_v_1 = {
"type": "text",
"track": 4,
"time": 0,
"y": "87.9086%",
"width": "100%",
"height": "40%",
"x_alignment": "50%",
"y_alignment": "50%",
"font_family": "Noto Sans",
"font_weight": "700",
"font_size": "8 vmin",
"background_color": "rgba(216,216,216,0)",
"background_x_padding": "33%",
"background_y_padding": "7%",
"background_border_radius": "28%",
"transcript_source": "audio-music", # audio-music과 연동됨
"transcript_effect": "karaoke",
"fill_color": "#ffffff",
"stroke_color": "rgba(51,51,51,1)",
"stroke_width": "0.6 vmin"
}
autotext_template_h_1 = {
"type": "text",
"track": 4,
"time": 0,
"x": "10%",
"y": "83.2953%",
"width": "80%",
"height": "15%",
"x_anchor": "0%",
"y_anchor": "0%",
"x_alignment": "50%",
"font_family": "Noto Sans",
"font_weight": "700",
"font_size": "5.9998 vmin",
"transcript_source": "audio-music",
"transcript_effect": "karaoke",
"fill_color": "#ffffff",
"stroke_color": "#333333",
"stroke_width": "0.2 vmin"
}
async def get_shared_client() -> httpx.AsyncClient: async def get_shared_client() -> httpx.AsyncClient:
"""공유 HTTP 클라이언트를 반환합니다. 없으면 생성합니다.""" """공유 HTTP 클라이언트를 반환합니다. 없으면 생성합니다."""
global _shared_client global _shared_client
@ -693,7 +736,10 @@ class CreatomateService:
text_scene["elements"][0]["name"] = f"lyric-{lyric_index}" text_scene["elements"][0]["name"] = f"lyric-{lyric_index}"
text_scene["elements"][0]["text"] = lyric_text text_scene["elements"][0]["text"] = lyric_text
return text_scene return text_scene
def auto_lyric(self, auto_text_template : dict):
text_scene = copy.deepcopy(auto_text_template)
return text_scene
def get_text_template(self): def get_text_template(self):
match self.orientation: match self.orientation:
@ -701,4 +747,11 @@ class CreatomateService:
return text_template_v_2 return text_template_v_2
case "horizontal": case "horizontal":
return text_template_h_1 return text_template_h_1
def get_auto_text_template(self):
match self.orientation:
case "vertical":
return autotext_template_v_1
case "horizontal":
return autotext_template_h_1

View File

@ -41,6 +41,8 @@ from app.video.schemas.video_schema import (
) )
from app.video.worker.video_task import download_and_upload_video_to_blob from app.video.worker.video_task import download_and_upload_video_to_blob
from config import creatomate_settings
logger = get_logger("video") logger = get_logger("video")
router = APIRouter(prefix="/video", tags=["Video"]) router = APIRouter(prefix="/video", tags=["Video"])
@ -348,17 +350,22 @@ async def generate_video(
f"[generate_video] timestamp[{i}]: lyric_line={ts.lyric_line}, start_time={ts.start_time}, end_time={ts.end_time}" f"[generate_video] timestamp[{i}]: lyric_line={ts.lyric_line}, start_time={ts.start_time}, end_time={ts.end_time}"
) )
text_template = creatomate_service.get_text_template() # LYRIC AUTO 결정부
for idx, aligned in enumerate(song_timestamp_list): if (creatomate_settings.DEBUG_AUTO_LYRIC):
caption = creatomate_service.lining_lyric( auto_text_template = creatomate_service.get_auto_text_template()
text_template, final_template["source"]["elements"].append(creatomate_service.auto_lyric(auto_text_template))
idx, else :
aligned.lyric_line, text_template = creatomate_service.get_text_template()
aligned.start_time, for idx, aligned in enumerate(song_timestamp_list):
aligned.end_time, caption = creatomate_service.lining_lyric(
) text_template,
final_template["source"]["elements"].append(caption) idx,
aligned.lyric_line,
aligned.start_time,
aligned.end_time,
)
final_template["source"]["elements"].append(caption)
# END - LYRIC AUTO 결정부
# logger.debug( # logger.debug(
# f"[generate_video] final_template: {json.dumps(final_template, indent=2, ensure_ascii=False)}" # f"[generate_video] final_template: {json.dumps(final_template, indent=2, ensure_ascii=False)}"
# ) # )

View File

@ -155,6 +155,10 @@ class CreatomateSettings(BaseSettings):
default=30.0, default=30.0,
description="가로형 템플릿 기본 duration (초)", description="가로형 템플릿 기본 duration (초)",
) )
DEBUG_AUTO_LYRIC: bool = Field(
default = False,
description = "Creatomate 자동 가사 생성 기능 사용 여부"
)
model_config = _base_config model_config = _base_config