python - Opencv 视频分析音频文件
问题描述
我正在使用 opencv 来分析视频。但是,在我使用 cv2.VideoCapture() 函数(使用 YOLO Darknet 分析)后,我无法检索音频文件。如何附加音频文件,使其像普通音频文件一样播放。
import cvlib as cv
from cvlib.object_detection import draw_bbox
import cv2
# open webcam
webcam = cv2.VideoCapture("143055.crf")
if not webcam.isOpened():
print("Could not open webcam")
exit()
image_counter=0
# loop through frames
while webcam.isOpened():
# read frame from webcam
status, frame = webcam.read()
if not status:
print("Could not read frame")
exit()
# apply object detection
bbox, label, conf = cv.detect_common_objects(frame)
print(bbox, label, conf)
# draw bounding box over detected objects
out = draw_bbox(frame, bbox, label, conf)
# display output
cv2.imshow("Real-time object detection", frame)
cv2.imwrite('/Users/dukeglacia/Downloads/test_images2/%d.jpg'%image_counter,frame)
image_counter+=1
# press "Q" to stop
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# release resources
webcam.release()
cv2.destroyAllWindows()
据我所知,cv2 只提取帧而不是音频,因此当我将帧转换回视频时,我得到一个无音频视频。
解决方案
推荐阅读
- python - 如何将一维列表中的元素替换为零比较另一个列表?
- html - 通过多个页面链接文本
- python - 带有 OpenAPI 3.0.1 的 SwaggerEditor 不显示响应 base64 PNG 图像
- python - 如何导入 tensorflow eminist 字母数据集?
- git - 修改并强制推送隔离分支后会发生什么
- c++ - c++:array 为什么初始化的时候需要两个大括号
- c# - 文件不下载/不显示查看文件的对话框
- javascript - this.setState()(react.Component 方法)如何访问他孩子的班级状态?
- javascript - Stripe Checkout 订阅付款失败重定向到过期链接页面
- ios - 移动 Web 使用 Angular 在 IOS 上启用推送通知