Howto :audio recording (script ready to be used for event)

A place for discussion of topics that are not specific to ZoneMinder. This could include Linux, Video4Linux, CCTV cameras or any other topic.
Post Reply
ktheking
Posts: 70
Joined: Fri Oct 12, 2007 11:53 am

Howto :audio recording (script ready to be used for event)

Post by ktheking »

Next to try : icecast2+liquidsoap (mp3-ogg streaming server + 3-ogg streaming client)

Purpose 1 : listen to current audio inputs ,icecast2 (first from regular audio cards)

Purpose of setup : create mp3-ogg streaming server which if being fed by audio input. The goal is to give a link in client browser window which then enables audio streaming on the moment itself (with a very small difference).

Purpose 2 : Do audio recording trough a locally installed audio streaming client into a physical file. (liquidsoap). Would be nice if liquidsoap would be able to record also streams from axis cams.

General purpose is to follow the same setup as the ZM video.

For now I will try to trigger the recording by a ZM video event.

In a later stage maybe it would be nice to get trigger events based on audio levels (remember the movie 'Mission Impossible' ,were Tom descends into vault getting the NOC list and couldn't make any noise ? ) .

But we'll see ...
Last edited by ktheking on Mon Oct 29, 2007 6:04 pm, edited 2 times in total.
ktheking
Posts: 70
Joined: Fri Oct 12, 2007 11:53 am

Post by ktheking »

This setup starts of with only 1 audio card. On success ,I'll extent to multiple.

Step 1 : configure audio card ,and check if proper audio entrance selected

launch alsamixer ,and select recording entrance.
#alsamixer

Launches graphical configtool in terminal.

-With 'Tab' key ,change view to 'capture'
-With 'Left'-'Right' arrow ,go to 'capture' column ,and put level to 70%
-With 'Left'-'Right' arrow go to preferred entrance,and press spacebar to select it.
-Press escape key to exit alsamixer.

Test the settings :
Connect audio device with cable to audio card (for example a radio).
Then launch this command :

arecord -f cd -d 10 -t raw | lame -x - out.mp3

This should now record an mp3 file named out.mp3 ,containing the audio you connected to the card.
Copy it to your windoze machine and test the file. You should hear the audio.
If not ,then fiddle around with alsamixer settings ,and the audio settings. (keep focused ,usually there is only 1 good combination to get this working).

Step 2 : install pre-requisite for streamcast :

see her below in next post ...
Last edited by ktheking on Mon Oct 29, 2007 5:52 pm, edited 1 time in total.
ktheking
Posts: 70
Joined: Fri Oct 12, 2007 11:53 am

Post by ktheking »

OK .. got the streaming stuff working :

Test if audio card is configured allright (if not use alsamixer):
arecord -f cd -d 10 -t raw | lame -x - out.mp3

Install needed packages for streaming :

PART1 : Set up shoutcast server

apt-get install lame
apt-get install vorbis-tools libvorbis-dev
apt-get install ices2



Configure icecast :
backup the original icecast config
#cp -p /etc/icecast2/icecast.xml /etc/icecast2/icecast.xml.ori

Change passwords and usernames to 'admin' .

#vi /etc/icecast2/icecast.xml

<source-password>admin</source-password>
<relay-password>admin</relay-password>
<admin-user>admin</admin-user>
<admin-password>admin</admin-password>


edit this file :
#vi /etc/default/icecast2

and change
from "ENABLE=false"
to "ENABLE=true"


Configure ice2 :

ice2 need paths :
#mkdir /var/log/ices
#mkdir /etc/ices2

ice2 xml config file :

#cp -p cp /usr/share/doc/ices2/examples/ices-alsa.xml /etc/ices2/ices-alsa.xml

change these values :
from <param name="rate">44100</param>
to <param name="rate">48000</param>

from <in-rate>44100</in-rate>
to <in-rate>48000</in-rate>

With most soundcards ,the 44100 option give problems. So change this to 44800




FIRST TEST : Start all applications


start icecast2 :
/etc/init.d/icecast2 start


start the streamserver :
ices2 /etc/ices2/ices-alsa.xml


Check logs for errors : /var/log/ices/ices.log


To check the icecast server config :
http://192.168.xxx.xxx:8000/server_version.xsl

To test your streaming :
Right now connect with winamp (or with another stream client ) to you running machine :
http://192.168.xxx.xxx:8000/example1.ogg


PART2 : Setup stream client : liquidsoap (savonet)

Just follow the guide here : http://savonet.sourceforge.net/wiki/wik ... ka=Savonet

For ubuntu install these lines are missing at the end :

useradd liquidsoap
make install

To test liquidsoap : Let's make a file based on our current running icecast server.

=> TODO
For external streaming (getting stream into mp3 file ):

Code: Select all

liquidsoap 'output.file.wav("/path/to/saved/file.wav",   \ 
        add([blank(),input.http("http://host:port/mountpoint")]))' 
example :

Code: Select all

sudo -u liquidsoap liquidsoap 'output.file.mp3("/tmp/file.mp3",add([blank(),input.http("http://scfire-dll-aa03.stream.aol.com/stream/1074")]))'

Used docs for creating this guide :
http://www.howtoforge.com/linux_webradi ... 2_ices2_p2 (doc for streaming with playlist)
http://www.communecation.net/pages/streaming.html (doc for streaming using darkice)
http://www.devshed.com/c/a/Multimedia/N ... h-Icecast/
http://savonet.sourceforge.net/wiki/wik ... tionUbuntu

FIRST CONCLUSIONS :

Has got much potential :
-the streaming works with a buffer ,thus enabling the possibility to do audio analysis just the same way ZM does :
This gives the possibility to :
-Here I'd like to get a VU meter application to monitor the sound level of the streaming app. IF ANYBODY KNOWS AN APP WHICH CAN DO THIS ,PLEASE PUT IT IN THIS POST !
-Get the audio recorded on approximately the same moment as the video recording of ZM starts !

-Working with streaming gives the ability to couple audio and browsers
-Seems to work well on local network ,with winamp streamclient. However doesn't work yet on the web .=> to verify.


TODO'S :
-Check if liquisoap is able to stream axis audio stream.
31/10/2007 update :
Here is described how the audio can be streamed seperately : http://www2.axis.com/files/developer/camera/audio.pdf
-Find application to monitor VU level in the audio stream
-Create script to record the audio stream into mp3 using 'liquidsoap'
-Find a way to get a flash app into page that is able to bring the audio into the browser. ( this site proves it can be done : http://wiihear.com/ , here you can enter shoutcast url into a flash application)
-Get this whole setup into ZM perl scripts and also database. (I am not able to do this one. My perl and database knowledge is not big enough
sjBrockley
Posts: 1
Joined: Wed Aug 06, 2008 5:17 pm
Location: London

Post by sjBrockley »

Hello

I manged to get this working but there was a delay of more than ten seconds in the audio passing from one PC on my desk to another PC on my office LAN. Presume this is encoding time? If so this is not good for ZM type application.


I see bounty for audio over here: http://www.zoneminder.com/forums/viewto ... ght=bounty

Regards
Steve
coke
Posts: 518
Joined: Wed Jan 30, 2008 5:53 pm
Location: St. Louis, MO, USA

Audio triggering

Post by coke »

Many of the axis (and apparently the ACTi's) I have include microphones, and can be set to trigger from the camera itself when there's a certain level of sound. Might make that part a little easier, at least.
Howie69
Posts: 11
Joined: Thu Jul 01, 2010 7:38 pm

Post by Howie69 »

Hrm. If using shoutcast, I could see how one could patch in a shoutcast client to stream the audio in synch with the video in the playback screen (but probably not the live view).

Couldn't there even be a java audio client that could be placed inline and run with cambozola?

Sure, use an external program for the capturing and such, but find a way to integrate it into the playback screen. Say an external 'plugin' or something?
Post Reply