Skip to content

Commit 0353499

Browse files
committed
Add ffmpeg_cmd parameter to run_ffmpeg_for_video_to_m4a_and_mp3 function
1 parent 2084f45 commit 0353499

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

app/celery_task/task/ytdl.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ def raise_if_task_not_runnable(task: celery_interface.SessionTask) -> None:
6060
raise task.retry(**retry_kwargs, exc=RuntimeError("Updater is running"))
6161

6262

63-
def run_ffmpeg_for_video_to_m4a_and_mp3(video_path: pt.Path, coverart_path: pt.Path) -> dict[str, pt.Path]:
63+
def run_ffmpeg_for_video_to_m4a_and_mp3(
64+
video_path: pt.Path,
65+
coverart_path: pt.Path,
66+
ffmpeg_cmd: str = "ffmpeg",
67+
) -> dict[str, pt.Path]:
6468
"""ffmpeg를 이용해 영상 파일을 m4a와 mp3 파일로 변환하는 명령어를 생성합니다."""
6569
target_video_path = video_path
6670
target_coverart_path = coverart_path
@@ -82,12 +86,12 @@ def run_ffmpeg_for_video_to_m4a_and_mp3(video_path: pt.Path, coverart_path: pt.P
8286
merged_node: ffmpeg.nodes.Node = ffmpeg.merge_outputs(mp3_output_node, m4a_output_node)
8387

8488
if docker_util.is_container():
85-
compiled_args: list[str] = ffmpeg.compile(merged_node, overwrite_output=True)
89+
compiled_args: list[str] = ffmpeg.compile(merged_node, overwrite_output=True, cmd=ffmpeg_cmd)
8690
stdout, stderr = docker_util.run_cmd_on_host(compiled_args)
8791
logger.warning(f"ffmpeg stdout:\n{stdout}")
8892
logger.warning(f"ffmpeg stderr:\n{stderr}")
8993
else:
90-
ffmpeg_run: tuple[str, str] = ffmpeg.run(merged_node, overwrite_output=True, quiet=True)
94+
ffmpeg_run: tuple[str, str] = ffmpeg.run(merged_node, overwrite_output=True, quiet=True, cmd=ffmpeg_cmd)
9195
stdout, stderr = ffmpeg_run
9296
logger.warning(f"ffmpeg stdout:\n{stdout}")
9397
logger.warning(f"ffmpeg stderr:\n{stderr}")
@@ -107,7 +111,8 @@ def ytdl_downloader_task(self: celery_interface.SessionTask[None], *, youtube_vi
107111
file_paths["video"] = download_info.file_path
108112
file_paths["thumbnail"] = youtube_util.download_thumbnail(youtube_vid, save_dir)
109113

110-
audio_paths = run_ffmpeg_for_video_to_m4a_and_mp3(file_paths["video"], file_paths["thumbnail"])
114+
ffmpeg_cmd = self.config_obj.project.ssco.ffmpeg_cmd
115+
audio_paths = run_ffmpeg_for_video_to_m4a_and_mp3(file_paths["video"], file_paths["thumbnail"], ffmpeg_cmd)
111116
file_paths |= audio_paths
112117
file_download_urls: dict[str, str] = {}
113118

app/config/project.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
class SSCoProjectSetting(pydantic_settings.BaseSettings):
1010
telegram_bot_token: pydantic.SecretStr
11+
ffmpeg_cmd: str = "ffmpeg"
1112

1213

1314
class ProjectSetting(pydantic_settings.BaseSettings):

0 commit comments

Comments
 (0)