将音频添加到从 OpenCV 生成的视频中 [英] Adding audio to video produced from OpenCV

查看:400
本文介绍了将音频添加到从 OpenCV 生成的视频中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 python 下的 OpenCV 从捕获中录制视频设备.每小时写入两个输出 AVI,在每小时的顶部更改文件名.其中一个文件是原始捕获文件,另一个文件使用了 OpenCV 的一些检测功能.

I've been using OpenCV under python to record video from a capture device. Two output AVI's are written each hour, at the top of each hour the file names are changed. One of the files is the original capture and one uses some of OpenCV's detection functions.

与往常一样,事情发生了变化,需要记录音频,这原本不是一个问题.我想知道是否有人对如何最好地做到这一点有任何建议.目前的想法是使用 pyaudio 单独录制音轨,然后在一个小时完成录制后使用 ffmpeg 将它们混合在一起,尽管我确实对保持准确的口型同步有一些担忧.

As always, things change and audio needs to be recorded which wasn't originally a concern. I'm wondering if anyone has any suggestions about how best to do this. Current thought is to separately record the audio track using pyaudio and then use ffmpeg to mux them together after the hour has finished recording although I do have some concerns about keeping accurate lipsync.

我想知道是否有人对如何准确地做到这一点并且在录音中没有明显差距有更好的想法?

I'm wondering if anyone has any better ideas about how to do this accurately and without noticeable gaps in the recording?

推荐答案

pyaudio 模块可能适合您的需求,它是 portaudio 的包装器.在 MacOsX 上,这个 hack 安装了 portaudio 库:

The pyaudio module may fit your needs, it is a wrapper aroung portaudio. On MacOsX, this hack installs the portaudio libray:

svn co https://www.portaudio.com/repos/portaudio/trunk portaudio
cd portaudio/
./configure
make
sudo make install
sudo /usr/bin/install -c -m 644 -m 644 ./include/pa_mac_core.h /usr/local/include/pa_mac_core.h
sudo easy_install pyaudio

查看他们的网站:http://people.csail.mit.edu/hubert/pyaudio/

这篇关于将音频添加到从 OpenCV 生成的视频中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆