python opencv无法编码h264、opencv编码的mp4视频无法在网页中播放

python opencv无法编码h264、opencv编码的mp4视频无法在网页中播放,这好像是因为开源许可的协议不同,导致python opencv中没有内置h264的编码,无法以h264的格式保存视频。

所以我就直接使用webm格式的视频:

output_path = 'output_video.webm'
output_codec = cv2.VideoWriter_fourcc(*'VP80')  # 使用VP8编解码器
output = cv2.VideoWriter(output_path, output_codec, fps, (frame_width, frame_height))

网页播放视频:

<!DOCTYPE html>
<html>
<head>
  <title>WebM Video Player</title>
</head>
<body>
  <video width="640" height="360" controls>
    <source src="http://127.0.0.1:8080/results/yolov5_flame_smog_videos/1688613185_result.webm" type="video/webm">
    Your browser does not support the video tag.
  </video>
</body>
</html>
posted @   好人~  阅读(1121)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示