feat(新功能): pose transform 部署
fix(修复bug): docs(文档变更): refactor(重构): test(增加测试):
This commit is contained in:
@@ -10,6 +10,12 @@ from minio import Minio
|
||||
from app.core.config import *
|
||||
from app.service.utils.new_oss_client import oss_upload_image
|
||||
|
||||
|
||||
# minio 配置
|
||||
MINIO_URL = "www.minio.aida.com.hk:12024"
|
||||
MINIO_ACCESS = 'vXKFLSJkYeEq2DrSZvkB'
|
||||
MINIO_SECRET = 'uKTZT3x7C43WvPN9QTc99DiRkwddWZrG9Uh3JVlR'
|
||||
MINIO_SECURE = True
|
||||
minio_client = Minio(MINIO_URL, access_key=MINIO_ACCESS, secret_key=MINIO_SECRET, secure=MINIO_SECURE)
|
||||
|
||||
|
||||
@@ -44,24 +50,44 @@ def upload_gif(gif_buffer, user_id, category, file_name):
|
||||
|
||||
def upload_video(frames, user_id, category, file_name):
|
||||
try:
|
||||
# 生成内存中的视频字节流
|
||||
video_buffer = io.BytesIO()
|
||||
with imageio.get_writer(video_buffer, format="mp4", fps=24) as writer:
|
||||
for img in frames:
|
||||
writer.append_data(img)
|
||||
writer.close()
|
||||
video_bytes = video_buffer.getvalue()
|
||||
|
||||
object_name = f'{user_id}/{category}/{file_name}'
|
||||
# 上传视频流到MinIO
|
||||
minio_client.put_object(
|
||||
bucket_name="aida-users",
|
||||
object_name=object_name,
|
||||
data=io.BytesIO(video_bytes),
|
||||
length=len(video_bytes),
|
||||
content_type="video/mp4"
|
||||
# 创建视频写入器
|
||||
fps = 24 # 帧率
|
||||
video_path = "output.mp4"
|
||||
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
||||
video_writer = cv2.VideoWriter(video_path, fourcc, fps, (768, 512))
|
||||
|
||||
# 逐帧写入
|
||||
for frame in frames:
|
||||
video_writer.write(cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)) # OpenCV需BGR格式
|
||||
video_writer.release()
|
||||
|
||||
minio_client.fput_object(
|
||||
"aida-users",
|
||||
object_name,
|
||||
video_path,
|
||||
content_type="video/mp4" # 指定MIME类型确保可在线播放[9](@ref)
|
||||
)
|
||||
return f"aida-users/{object_name}"
|
||||
|
||||
# # 生成内存中的视频字节流
|
||||
# video_buffer = io.BytesIO()
|
||||
# with imageio.get_writer(video_buffer, format="mp4", fps=24) as writer:
|
||||
# for img in frames:
|
||||
# writer.append_data(img)
|
||||
# writer.close()
|
||||
# video_bytes = video_buffer.getvalue()
|
||||
#
|
||||
# object_name = f'{user_id}/{category}/{file_name}'
|
||||
# # 上传视频流到MinIO
|
||||
# minio_client.put_object(
|
||||
# bucket_name="aida-users",
|
||||
# object_name=object_name,
|
||||
# data=io.BytesIO(video_bytes),
|
||||
# length=len(video_bytes),
|
||||
# content_type="video/mp4"
|
||||
# )
|
||||
# return f"aida-users/{object_name}"
|
||||
except Exception as e:
|
||||
logging.warning(f"upload_video runtime exception : {e}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user