tchellomello / python-amcrest

A Python 2.7/3.x module for Amcrest and Dahua Cameras using the SDK HTTP API.
GNU General Public License v2.0
213 stars 76 forks source link

Sending audio stream makes camera unresponsive #98

Open danobot opened 5 years ago

danobot commented 5 years ago

I am sendnig some audio which plays fine on the camera, however I am then unable to send subsequent streams or query the API for information such as SD card capacity. This is the documentation I followed.

        this_camera = get_camera(call);
        file=call.data.get(ATTR_FILE);
        _LOGGER.info("Playing {} on {}".format(file,call.data[ATTR_ENTITY_ID]));
        # this_camera.play_wav(httptype='singlepart', path_file=file);
        result = this_camera.audio_send_stream(httptype='singlepart', channel=1, path_file=file, encode='MPEG2');
        _LOGGER.info(dir(result));
        return result == 'OK';

The audio_send_stream method does not return, which explains the symptoms. Is there anything I am missing in my code? Do I have to close some stream manually? Tried singlepart and multipart and had the same problem with the commented out attempt at play_wav. The only way to send more audio is by rebooting the camera.

danobot commented 5 years ago

I am working on adding some more integrations to the Amcrest Camera component for Home Assistant. Any help would be appreciated in getting this resolved. Have got the PTZ preset control working already, this is a blocker though as I cannot figure out what is wrong.

aredon commented 11 months ago

I realize this is pretty obscure and old but I've been using this method to push audio to my camera and play a welcome home message for like 5 years now. I'm moving my setup over into home assistant (and trying to figure out how to move this script) I saw you asking around so here it is for posterity:

curl --limit-rate 8K \ -F "file=@/var/lib/sounds/welcome_home.al;type=Audio/G.711A" \ -H "Content-Type: Audio/G.711A" \ -m 5 \ http://USERNAME:PASSWORD@192.168.1.100:37779/cgi-bin/audio.cgi\?action\=postAudio\&httptype\=singlepart\&channel\=1

If memory serves I could only get it to play .al files. I forget where I learned that from. There was also an issue with the playback speed of the audio being quite messed up so some fancy command had to be used to edit the file. Unfortunately I've lost track of that too and will need to dig it back up...