feat(新功能):

fix(修复bug):   pose transform 模块 upload video 保存地址修改
docs(文档变更):
refactor(重构):
test(增加测试):
This commit is contained in:
zchengrong
2025-04-22 14:27:20 +08:00
parent 66fa349e99
commit ac9c9b016d

View File

@@ -49,24 +49,24 @@ def upload_gif(gif_buffer, user_id, category, file_name):
def upload_video(frames, user_id, category, file_name): def upload_video(frames, user_id, category, file_name):
try: try:
ndarray_to_video(frames, file_name) save_path = ndarray_to_video(frames, file_name)
object_name = f'{user_id}/{category}/{file_name}' object_name = f'{user_id}/{category}/{file_name}'
minio_client.fput_object( minio_client.fput_object(
"aida-users", "aida-users",
object_name, object_name,
file_name, save_path,
content_type="video/mp4" # 指定MIME类型确保可在线播放[9](@ref) content_type="video/mp4" # 指定MIME类型确保可在线播放[9](@ref)
) )
print(file_name)
return f"aida-users/{object_name}" return f"aida-users/{object_name}"
except Exception as e: except Exception as e:
logging.warning(f"upload_video runtime exception : {e}") logging.warning(f"upload_video runtime exception : {e}")
def ndarray_to_video(images, output_path, frame_size=(512, 768), fps=9): 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( writer = skvideo.io.FFmpegWriter(
os.path.join(POSE_TRANSFORM_VIDEO_PATH,output_path), save_path,
inputdict={'-r': str(fps)}, inputdict={'-r': str(fps)},
outputdict={'-r': str(fps), '-vcodec': 'libx264'} 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() writer.close()
return save_path
if __name__ == '__main__': if __name__ == '__main__':