优化代码
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
import io
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
import cv2
|
||||
|
||||
from loguru import logger
|
||||
|
||||
|
||||
def _get_first_frame(video_path, output_path):
|
||||
def get_first_frame(video_path, output_path):
|
||||
"""
|
||||
提取视频的第一帧并保存为图片
|
||||
:param video_path: 视频文件路径
|
||||
@@ -50,7 +48,7 @@ def _get_first_frame(video_path, output_path):
|
||||
cap.release()
|
||||
|
||||
|
||||
def _get_first_frame_bytes(video_bytes, output_path):
|
||||
def get_first_frame_bytes(video_bytes, output_path):
|
||||
"""
|
||||
提取视频的第一帧并保存为图片
|
||||
:param video_bytes: 视频文件流
|
||||
@@ -65,7 +63,7 @@ def _get_first_frame_bytes(video_bytes, output_path):
|
||||
temp_file.write(video_bytes)
|
||||
temp_file_path = temp_file.name # 获取临时文件路径
|
||||
# 打开视频文件
|
||||
return _get_first_frame(temp_file_path, output_path)
|
||||
return get_first_frame(temp_file_path, output_path)
|
||||
except Exception as e:
|
||||
logger.error(f"提取视频首帧时出错: {e}")
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user