Mrs4s / go-cqhttp

cqhttp的golang实现,轻量、原生跨平台.
GNU Affero General Public License v3.0
10.37k stars 1.63k forks source link

[Bug]: videoCQ码转换失败 [CQ:video,file=/data/bot/noneBot2/nonebot2/plugins/aaa.mp4] #1718

Closed yixuan1912 closed 2 years ago

yixuan1912 commented 2 years ago

请确保您已阅读以上注意事项,并勾选下方的确认框。

go-cqhttp 版本

v1.0.0-rc3

运行环境

Ubuntu

运行架构

ARM [64] (别名:AArch64 / ARMv8)

连接方式

WebSocket (反向)

使用协议

0 | iPad

重现步骤

已经尝试使用了 ffmpeg 将视频转换,但是还是无法发送

期望的结果是什么?

成功发送视频

实际的结果是什么?

转换CQ码 ({"type": "video", "data": {"file": "/data/bot/noneBot2/nonebot2/plugins/aaa.mp4", "cache": null, "proxy": null, "timeout": null}}) 到MiraiGo Element时出现错误: invalid video 将忽略本段CQ码.

简单的复现代码/链接(可选)

#下面是我用 ffmpeg 将视频转换的代码
video_path = os.path.join(os.path.join(os.path.join(BASE_DIR, 'nonebot2'), 'plugins'), 'ttt.mp4')
output = os.path.join(os.path.dirname(video_path), "aaa.mp4")

# 使用ffmpeg 合并视频和音频
from ffmpy import FFmpeg
translator = FFmpeg(
    executable=r'E:\ffmpeg\bin\ffmpeg.exe',
    inputs={
        video_path: None,
    },
    outputs={
        output: '-c:v copy -strict experimental'
    }
)

translator.run()

日志记录(可选)

No response

补充说明(可选)

No response

MingxuanGame commented 2 years ago

如果你使用 nonebot2 可以使用 MessageSegment.video 传入 pathlib.Path 来发送本地视频文件

参考: pathlib 文档:https://docs.python.org/zh-cn/3/library/pathlib.html MessageSegment.video 文档:https://onebot.adapters.nonebot.dev/docs/api/v11/message#MessageSegment-video

如果直接传入,需要添加 file://,即 file:///data/bot/noneBot2/nonebot2/plugins/aaa.mp4

yixuan1912 commented 2 years ago

如果你使用 nonebot2 可以使用 MessageSegment.video 传入 pathlib.Path 来发送本地视频文件

参考: pathlib 文档:https://docs.python.org/zh-cn/3/library/pathlib.html MessageSegment.video 文档:https://onebot.adapters.nonebot.dev/docs/api/v11/message#MessageSegment-video

如果直接传入,需要添加 file://,即 file:///data/bot/noneBot2/nonebot2/plugins/aaa.mp4

感谢,我忘记了需要设置成 file路径了