From ac9c9b016d0cfe0ed7cbf4ba46cb8ceb92c286b3 Mon Sep 17 00:00:00 2001 From: zchengrong <124802516+zchengrong@users.noreply.github.com> Date: Tue, 22 Apr 2025 14:27:20 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=88=E6=96=B0=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=89:=20fix=EF=BC=88=E4=BF=AE=E5=A4=8Dbug=EF=BC=89:=20=20?= =?UTF-8?q?=20pose=20transform=20=E6=A8=A1=E5=9D=97=20upload=20video=20?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=9C=B0=E5=9D=80=E4=BF=AE=E6=94=B9=20docs?= =?UTF-8?q?=EF=BC=88=E6=96=87=E6=A1=A3=E5=8F=98=E6=9B=B4=EF=BC=89:=20refac?= =?UTF-8?q?tor=EF=BC=88=E9=87=8D=E6=9E=84=EF=BC=89:=20test(=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=B5=8B=E8=AF=95):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../generate_image/utils/pose_transform_upload.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/service/generate_image/utils/pose_transform_upload.py b/app/service/generate_image/utils/pose_transform_upload.py index 4ecb35d..71d31ef 100644 --- a/app/service/generate_image/utils/pose_transform_upload.py +++ b/app/service/generate_image/utils/pose_transform_upload.py @@ -49,24 +49,24 @@ def upload_gif(gif_buffer, user_id, category, file_name): def upload_video(frames, user_id, category, file_name): try: - ndarray_to_video(frames, file_name) + save_path = ndarray_to_video(frames, file_name) object_name = f'{user_id}/{category}/{file_name}' minio_client.fput_object( "aida-users", object_name, - file_name, + save_path, content_type="video/mp4" # 指定MIME类型确保可在线播放[9](@ref) ) - print(file_name) return f"aida-users/{object_name}" except Exception as e: logging.warning(f"upload_video runtime exception : {e}") def ndarray_to_video(images, output_path, frame_size=(512, 768), fps=9): + save_path = os.path.join(POSE_TRANSFORM_VIDEO_PATH, output_path) # 初始化视频写入器 writer = skvideo.io.FFmpegWriter( - os.path.join(POSE_TRANSFORM_VIDEO_PATH,output_path), + save_path, inputdict={'-r': str(fps)}, outputdict={'-r': str(fps), '-vcodec': 'libx264'} ) @@ -80,6 +80,7 @@ def ndarray_to_video(images, output_path, frame_size=(512, 768), fps=9): # 关闭写入器 writer.close() + return save_path if __name__ == '__main__':