新增API

- /ffmpeg/subtitle-apply
- /ffmpeg/bgm-nosie-reduce
- /ffmpeg/zoom-loop
- /ffmpeg/overlay-gif

增加modal环境变量.runtime.env
This commit is contained in:
shuohigh@gmail.com
2025-05-15 15:53:37 +08:00
parent 0fca52a271
commit 9f25ec0ced
9 changed files with 167 additions and 164 deletions

View File

@@ -1,9 +1,11 @@
import modal
from dotenv import dotenv_values
ffmpeg_worker_image = (
modal.Image.debian_slim(python_version="3.11")
.apt_install('ffmpeg')
.pip_install_from_pyproject("pyproject.toml")
.env(dotenv_values("../../.runtime.env"))
.add_local_python_source('cluster')
.add_local_python_source('BowongModalFunctions')
)
@@ -27,17 +29,9 @@ with ffmpeg_worker_image.imports():
from BowongModalFunctions.models.web_model import SentryTransactionInfo
from BowongModalFunctions.config import WorkerConfig
config = WorkerConfig(
app_name="bowong-ai-video-test",
video_downloader_concurrency=10,
ffmpeg_worker_concurrency=10,
modal_kv_name="media-cache",
s3_region='ap-northeast-2',
s3_bucket_name="modal-media-cache",
environment="dev"
)
config = WorkerConfig()
s3_mount = config.s3_mount_dir
s3_mount = config.S3_mount_dir
output_path_prefix = "/mnt/outputs"
sentry_sdk.init(
@@ -46,7 +40,7 @@ with ffmpeg_worker_image.imports():
add_full_stack=True,
shutdown_timeout=2,
traces_sample_rate=1.0,
environment=config.environment,
environment=config.modal_environment,
)
@@ -107,7 +101,7 @@ with ffmpeg_worker_image.imports():
os.makedirs(out_s3_dir, exist_ok=True)
shutil.copy(output, out_s3)
s3_outputs.append(
out_s3.replace(s3_mount + '/', f"s3://{config.s3_region}/{config.s3_bucket_name}/"))
out_s3.replace(s3_mount + '/', f"s3://{config.S3_region}/{config.S3_bucket_name}/"))
return s3_outputs
@@ -118,9 +112,9 @@ with ffmpeg_worker_image.imports():
max_containers=config.ffmpeg_worker_concurrency,
volumes={
f"/mntS3": modal.CloudBucketMount(
bucket_name=config.s3_bucket_name,
bucket_name=config.S3_bucket_name,
secret=modal.Secret.from_name("aws-s3-secret",
environment_name=config.environment),
environment_name=config.modal_environment),
),
}, )
@modal.concurrent(max_inputs=1)
@@ -154,9 +148,9 @@ with ffmpeg_worker_image.imports():
max_containers=config.ffmpeg_worker_concurrency,
volumes={
f"/mntS3": modal.CloudBucketMount(
bucket_name=config.s3_bucket_name,
bucket_name=config.S3_bucket_name,
secret=modal.Secret.from_name("aws-s3-secret",
environment_name=config.environment),
environment_name=config.modal_environment),
),
},
)
@@ -275,9 +269,9 @@ with ffmpeg_worker_image.imports():
max_containers=config.ffmpeg_worker_concurrency,
volumes={
f"/mntS3": modal.CloudBucketMount(
bucket_name=config.s3_bucket_name,
bucket_name=config.S3_bucket_name,
secret=modal.Secret.from_name("aws-s3-secret",
environment_name=config.environment),
environment_name=config.modal_environment),
),
},
)
@@ -311,9 +305,9 @@ with ffmpeg_worker_image.imports():
max_containers=config.ffmpeg_worker_concurrency,
volumes={
f"/mntS3": modal.CloudBucketMount(
bucket_name=config.s3_bucket_name,
bucket_name=config.S3_bucket_name,
secret=modal.Secret.from_name("aws-s3-secret",
environment_name=config.environment),
environment_name=config.modal_environment),
),
}, )
@modal.concurrent(max_inputs=1)
@@ -353,9 +347,9 @@ with ffmpeg_worker_image.imports():
max_containers=config.ffmpeg_worker_concurrency,
volumes={
f"/mntS3": modal.CloudBucketMount(
bucket_name=config.s3_bucket_name,
bucket_name=config.S3_bucket_name,
secret=modal.Secret.from_name("aws-s3-secret",
environment_name=config.environment),
environment_name=config.modal_environment),
),
}, )
@modal.concurrent(max_inputs=1)
@@ -387,9 +381,9 @@ with ffmpeg_worker_image.imports():
max_containers=config.ffmpeg_worker_concurrency,
volumes={
f"/mntS3": modal.CloudBucketMount(
bucket_name=config.s3_bucket_name,
bucket_name=config.S3_bucket_name,
secret=modal.Secret.from_name("aws-s3-secret",
environment_name=config.environment),
environment_name=config.modal_environment),
),
}, )
@modal.concurrent(max_inputs=1)
@@ -421,9 +415,9 @@ with ffmpeg_worker_image.imports():
max_containers=config.ffmpeg_worker_concurrency,
volumes={
f"/mntS3": modal.CloudBucketMount(
bucket_name=config.s3_bucket_name,
bucket_name=config.S3_bucket_name,
secret=modal.Secret.from_name("aws-s3-secret",
environment_name=config.environment),
environment_name=config.modal_environment),
),
}, )
@modal.concurrent(max_inputs=1)
@@ -464,9 +458,9 @@ with ffmpeg_worker_image.imports():
max_containers=config.ffmpeg_worker_concurrency,
volumes={
f"/mntS3": modal.CloudBucketMount(
bucket_name=config.s3_bucket_name,
bucket_name=config.S3_bucket_name,
secret=modal.Secret.from_name("aws-s3-secret",
environment_name=config.environment),
environment_name=config.modal_environment),
),
}, )
@modal.concurrent(max_inputs=1)