Skip to content

Audio Playback

gtxaspec edited this page Dec 23, 2023 · 6 revisions

Playing Audio on Wyze Cameras

You can play audio files or stream audio through your Wyze camera's speaker using the cmd aplay command.

Playing Audio Files

To play a .wav audio file, use the command cmd aplay <path-to-file> <volume>. The <volume> parameter sets the playback volume.

For example:

cmd aplay /path/to/audio.wav 50

This plays the audio.wav file at 50% volume.

Converting Audio Files to Compatible Format

If you have a .wav file that's not compatible, you can convert it using ffmpeg:

ffmpeg -i input.wav -acodec pcm_s16le -ac 1 -ar 16000 output.wav

This command converts input.wav into a format suitable for the camera.

Streaming Audio from Online Sources

To stream audio from an online radio station or other streaming sources, follow these steps:

  1. Create a FIFO buffer:

    mkfifo /opt/wz_mini/tmp/stream
    
  2. Stream and convert the audio using ffmpeg:

    • For Wyze Cam V2:
      ffmpeg -nostdin -f mp3 -i <stream-url> -c:a pcm_s16le -f s16le -ac 1 -ar 8000 pipe:1 > /opt/wz_mini/tmp/stream 2> /dev/null &
      
    • For Wyze Cam V3:
      ffmpeg -nostdin -f mp3 -i <stream-url> -c:a pcm_s16le -f s16le -ac 1 -ar 16000 pipe:1 > /opt/wz_mini/tmp/stream 2> /dev/null &
      

    Replace <stream-url> with the URL of your audio stream.

  3. Play the streamed audio:

    cmd aplay /opt/wz_mini/tmp/stream 30 2> /dev/null &
    

    This command plays the stream at 30% volume.

Stopping Audio Playback

To stop the playback, terminate the ffmpeg process and remove the FIFO buffer:

pkill ffmpeg
rm -f /opt/wz_mini/tmp/stream

These commands provide a flexible way to use your Wyze camera for audio playback, whether it's for playing specific audio files or streaming from online sources.