feat(新功能):
fix(修复bug): pose transform 图片合成视频方法更换 docs(文档变更): refactor(重构): test(增加测试):
This commit is contained in:
@@ -3,9 +3,9 @@ import logging
|
||||
import os.path
|
||||
|
||||
import numpy as np
|
||||
import skvideo.io
|
||||
# import boto3
|
||||
from minio import Minio
|
||||
from moviepy.video.io.ImageSequenceClip import ImageSequenceClip
|
||||
|
||||
from app.core.config import *
|
||||
from app.service.utils.new_oss_client import oss_upload_image
|
||||
@@ -63,23 +63,10 @@ def upload_video(frames, user_id, category, file_name):
|
||||
|
||||
|
||||
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(
|
||||
save_path,
|
||||
inputdict={'-r': str(fps)},
|
||||
outputdict={'-r': str(fps), '-vcodec': 'libx264'}
|
||||
)
|
||||
# 逐帧写入
|
||||
for frame in images:
|
||||
# 调整尺寸(可选)
|
||||
# resized_frame = cv2.resize(frame, frame_size)
|
||||
# 转换颜色通道(若需从 BGR 转 RGB)
|
||||
# rgb_frame = cv2.cvtColor(resized_frame, cv2.COLOR_BGR2RGB)
|
||||
writer.writeFrame(frame)
|
||||
save_path = os.path.join(r"E:\workspace\trinity_client_aida\app\service\generate_image\pose_transform_video", output_path)
|
||||
clip = ImageSequenceClip([frame for frame in images], fps=fps)
|
||||
clip.write_videofile(save_path, codec='libx264')
|
||||
|
||||
# 关闭写入器
|
||||
writer.close()
|
||||
return save_path
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user