优化一下时长计算问题
This commit is contained in:
@@ -237,7 +237,15 @@ class MessageMixin(WechatAPIClientBase):
|
|||||||
media_info = MediaInfo.parse(video_path)
|
media_info = MediaInfo.parse(video_path)
|
||||||
else:
|
else:
|
||||||
raise ValueError("video should be str, bytes, or path")
|
raise ValueError("video should be str, bytes, or path")
|
||||||
duration = media_info.tracks[0].duration
|
# 获取视频时长
|
||||||
|
duration = None
|
||||||
|
for track in media_info.tracks:
|
||||||
|
if track.track_type == "Video" and track.duration is not None:
|
||||||
|
duration = track.duration / 1000 # 将毫秒转换为秒
|
||||||
|
break
|
||||||
|
if duration is None:
|
||||||
|
duration = 1
|
||||||
|
self.logging.error(f"无法从视频文件获取时长: {video}")
|
||||||
|
|
||||||
# get image base64
|
# get image base64
|
||||||
if isinstance(image, str):
|
if isinstance(image, str):
|
||||||
|
|||||||
Reference in New Issue
Block a user