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>