Monday, May 28, 2018

How to send audio API HIKVISION for two-way-audio?

Leave a Comment

I need help to understand why when sending audio to the camera you hear ugly, very fast. The camera is configured audio codec G711Ulaw

The process I am doing is the following:

  • I download a wav audio and converted to the codec that the camera is configured, these are all evidence conversions.

    ffmpeg -i padrino.wav -acodec pcm_mulaw -ar 8000 -ac 1 -b:a 32k output.wav   ffmpeg -i padrino.wav -acodec pcm_mulaw -ar 8000 -ac 2 -b:a 32000 output.wav   ffmpeg -i padrino.wav -f mulaw -acodec pcm_mulaw -ac 1 output.wav   ffmpeg -i padrino.wav -ar 8000 -ac 1 -ab 64k -f mulaw output.ulaw 
  • Turned on the two-way-audio, within the "data.xml" is the xml that enables two-way-audio:

    curl -H "application/xml" -X PUT -d @data.xml USER:PASS@IPCAM/ISAPI/System/...hannels/1/open 
  • I send through a curl

    curl -H "application/binary" -X PUT -d @output.ulaw USER:PASS@IPCAM/ISAPI/System/...ls/1/audioData 

    or

    curl -H "application/binary" -X PUT -d @output.wav USER:PASS@IPCAM/ISAPI/System/...ls/1/audioData 

This is heard in camera but as I explained at the beginning is heard wrong, I distorted, very fast. What am I doing wrong?

regards

1 Answers

Answers 1

I have found out why this is - its nothing to do with the encoding. I have written a C# app to test this and if you send the data at the rate expected (8000 samples per second) then it plays correctly.

I send the audio data in packets (160 bytes currently but experimenting with optimum values but does not seem to matter much as long as the delay is correct) and delay for the appropriate amount of time before sending again so that the correct amount of samples are sent in a second.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment