Add audio to videos created with OpenCV

I used OpenCV under python to record video from a capture device. Two AVI outputs are recorded every hour, at the top of each hour the file names are changed. One of the files is the original capture, and it uses some OpenCV detection features.

As always, everything changes, and you need to record a sound that did not initially cause concern. I am wondering if anyone has any suggestions on how best to do this. The current thought is to record the soundtrack separately with pyaudio, and then use ffmpeg to combine them together after an hour has finished recording, although I have some problems keeping the exact lipync.

I am wondering if anyone has any better ideas on how to do this accurately and without noticeable spaces in the record?

+2
source share
2 answers

The pyaudio module can suit your needs, it is aroung portaudio shell. On Mac OSX, this hack installs 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 

Check out their website: http://people.csail.mit.edu/hubert/pyaudio/

+1
source

Since no better solutions appeared and were not used for anyone else, I went with my original plan and recorded the sound using PyAudio.

I actually use mencoder, which is called using POpen using pipe for stdout and stderr, then some regular expressions are used to verify that the work was successful, and I got good enough results for my application, although the sound is sometimes a frame or two.

0
source

Source: https://habr.com/ru/post/1336297/


All Articles