Pogoplug audio baby monitor

Ask questions about Arch Linux ARM. Please search before making a new topic.

Pogoplug audio baby monitor

Postby permitivity » Sun Jul 21, 2013 4:43 am

Hey all,
Does anyone know of an app that allows you to use a USB audio input device (like USB sound card or USB webcam w/ mic) - and stream the audio somehow. Looking to use it as a baby monitor for just the audio portion. I have a old smart phone that can be used as the parent device to listen to the audio.

My searching didn't turn up anything - mostly just audio streaming of music files.

Thanks much.
permitivity
 
Posts: 141
Joined: Mon Feb 18, 2013 3:08 am

Re: Pogoplug audio baby monitor

Postby permitivity » Sun Sep 01, 2013 12:32 am

Finally got something that works. Kind of cross posting from another one of my threads, but others might be interested in a pogoplug baby monitor. This uses ffmpeg and a usb webcam with built in microphone.

This is the command:
$this->bbcode_second_pass_quote('', '
')ffmpeg -re -f alsa -i plughw:0 -acodec mp2 -ab 192000 -ar 48000 -ac 1 -filter 'bandpass=f=1000:csg=0:width_type=q:w=.806' -f rtp rtp://224.1.2.3:1234


Using ffmpeg, you start a multicast rtp session. The -ab and -ar flags are bitrate and sampling rate, respectively. Because these webcam microphones have quite a bit of noise, use the filter parameters to filter out the low frequency buzz or high frequency squeech. More about filters can be found on this webpage. Worth playing with to clean up audio.

http://ffmpeg.org/ffmpeg-filters.html#bandpass

On the client device, connect to rtp://224.1.2.3:1234. This is the address for the multicast resource, not the IP address of the Pogoplug. I'm using an Android phone running VLC to listen to the stream. Still searching for a better app on the client side. I think you can also use another pogoplug with a USB sound card to output the sound to a speaker. Something like "ffplay rtp://224.1.2.3:1234". I'll try that later.

The ffmpeg process uses about 30% CPU, and the bandwidth needed is about 200 kbps (kilobits). The client device should buffer the stream to make the audio smoother. On wireless, there's some skipping if you don't put in a couple seconds buffer.

I thought making this start on boot would be easy. Saw this trick done by Qui's Pogoplug tutorial with Motion. If someone can help me figure it out, please post.

To make the pogoplug run at startup, create a .service file like this (thanks to moonman for fixing this for me):

$this->bbcode_second_pass_quote('', '
')nano /etc/systemd/system/baby_monitor.service


Paste this into the baby_monitor.service text file.

$this->bbcode_second_pass_code('', '
[Unit]
Description=baby monitor
After=network.target

[Service]
ExecStart=/usr/bin/ffmpeg -re -f alsa -i plughw:0 -acodec mp2 -ab 192000 -ar 48000 -ac 1 -filter 'bandpass=f=1000:csg=0:width_type=q:w=.806' -f rtp rtp://224.1.2.3:1234

[Install]
WantedBy=multi-user.target
')

Then make the service run at startup with
$this->bbcode_second_pass_quote('', '
')systemctl enable baby_monitor.service


Or to start or stop it manually:

$this->bbcode_second_pass_quote('', '
')systemctl start baby_monitor.service
systemctl stop baby_monitor.service
Last edited by permitivity on Sun Sep 01, 2013 4:01 am, edited 2 times in total.
permitivity
 
Posts: 141
Joined: Mon Feb 18, 2013 3:08 am
Top

Re: Pogoplug audio baby monitor

Postby moonman » Sun Sep 01, 2013 1:17 am

You may need to add After=network.target under unit section so it starts only after the network is up. Alao, why do you have the execpre in there with some video stuff if you only use audio?
Pogoplug V4 | GoFlex Home | Raspberry Pi 4 4GB | CuBox-i4 Pro | ClearFog | BeagleBone Black | Odroid U2 | Odroid C1 | Odroid XU4
-----------------------------------------------------------------------------------------------------------------------
[armv5] Updated U-Boot | [armv5] NAND Rescue System
moonman
Developer
 
Posts: 3388
Joined: Sat Jan 15, 2011 3:36 am

Re: Pogoplug audio baby monitor

Postby permitivity » Sun Sep 01, 2013 3:50 am

Thanks Moonman, that's what I needed was the network.target line. I'll edit my post with that in the .service file.

But I didn't know I was using some video stuff in the ffmpeg command. What video stuff?

Edit: Oh yeah, I see it. That was from some other .service file. I'll edit it out.
permitivity
 
Posts: 141
Joined: Mon Feb 18, 2013 3:08 am

Re: Pogoplug audio baby monitor

Postby permitivity » Fri Sep 06, 2013 2:16 am

Ok, I'm trying to play the rtp audio from the server on another Pogoplug using C-media usb audio adapter. But I haven't been able to figure out the correct commands.

$this->bbcode_second_pass_quote('', '
')[root@alarm media]# ffmpeg rtp://224.1.2.3:1234/
[....]
[NULL @ 0x49e20] Unable to find a suitable output format for 'rtp://224.1.2.3:1234/'
rtp://224.1.2.3:1234/: Invalid argument



$this->bbcode_second_pass_quote('', '
')[root@alarm media]# ffmpeg rtp://@224.1.2.3:1234/
[....]
[NULL @ 0x49e20] Unable to find a suitable output format for 'rtp://224.1.2.3:1234/'
rtp://224.1.2.3:1234/: Invalid argument


I tried VLC too, but that didn't work. Can't run as root apparently.
$this->bbcode_second_pass_quote('', '
')[root@alarm media]# vlc --rtp-caching 50 rtp://@224.1.2.3:1234/
VLC is not supposed to be run as root. Sorry.
If you need to use real-time priorities and/or privileged TCP ports
you can use vlc-wrapper (make sure it is Set-UID root and
cannot be run by non-trusted users first).


Any ideas on how to getting the Pogoplug to play RTP audio?
permitivity
 
Posts: 141
Joined: Mon Feb 18, 2013 3:08 am
Top

Re: Pogoplug audio baby monitor

Postby moonman » Fri Sep 06, 2013 7:09 am

Isn't it ffplay for playing? and ffmpeg for encoding
Pogoplug V4 | GoFlex Home | Raspberry Pi 4 4GB | CuBox-i4 Pro | ClearFog | BeagleBone Black | Odroid U2 | Odroid C1 | Odroid XU4
-----------------------------------------------------------------------------------------------------------------------
[armv5] Updated U-Boot | [armv5] NAND Rescue System
moonman
Developer
 
Posts: 3388
Joined: Sat Jan 15, 2011 3:36 am

Re: Pogoplug audio baby monitor

Postby permitivity » Fri Sep 06, 2013 11:29 pm

I tried ffplay:

$this->bbcode_second_pass_quote('', '
')ffplay rtp://224.1.2.3:1234/
Could not initialize SDL - No available video device
(Did you set the DISPLAY variable?)


I think there's suppose to be a way to tell ffplay to expect audio only.
permitivity
 
Posts: 141
Joined: Mon Feb 18, 2013 3:08 am
Top

Re: Pogoplug audio baby monitor

Postby moonman » Sat Sep 07, 2013 1:55 am

How abou this:

$this->bbcode_second_pass_code('', ' ffmpeg -i <your rtp stream> -f alsa default ')

Or get some console driven audio player.

For vlc, creating a user is an option.
Pogoplug V4 | GoFlex Home | Raspberry Pi 4 4GB | CuBox-i4 Pro | ClearFog | BeagleBone Black | Odroid U2 | Odroid C1 | Odroid XU4
-----------------------------------------------------------------------------------------------------------------------
[armv5] Updated U-Boot | [armv5] NAND Rescue System
moonman
Developer
 
Posts: 3388
Joined: Sat Jan 15, 2011 3:36 am

Re: Pogoplug audio baby monitor

Postby permitivity » Sat Sep 07, 2013 2:52 am

Yup, that works! Thanks.

$this->bbcode_second_pass_quote('', 'f')fmpeg -i rtp://224.1.2.3:1234 -f alsa default


In case someone else searches for this in the future:

use "alsamixer" to change volume, and esc and "alsactl store" to save the settings.
permitivity
 
Posts: 141
Joined: Mon Feb 18, 2013 3:08 am
Top

Re: Pogoplug audio baby monitor

Postby permitivity » Sat Sep 07, 2013 3:50 am

Another interesting problem. The parent part of the baby monitor, the part that plays the audio to speakers, runs fine when connected to hardwired ethernet. But when I used a wireless USB adapter, it doesn't work.

I've tried putting the USB wireless adapter on a powered USB 2 hub, and wireless connects. But the ffmpeg command to play the rtp stream doesn't work. It's not that the sound card isn't working either, it is. I can use mpg123 to play mp3s while the pogo is using wireless lan.

This is the output when connected to ethernet:
$this->bbcode_second_pass_code('', '
ffmpeg -i rtp://224.1.2.3:1234 -f alsa default
ffmpeg version 2.0.1 Copyright (c) 2000-2013 the FFmpeg developers
built on Aug 11 2013 09:58:44 with gcc 4.7.2 (GCC)
configuration: --prefix=/usr --disable-debug --disable-static --enable-avresam ple --enable-dxva2 --enable-fontconfig --enable-gpl --enable-libass --enable-lib bluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3l ame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg - -enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --en able-libspeex --enable-libtheora --enable-libv4l2 --enable-libvorbis --enable-li bvpx --enable-libx264 --enable-libxvid --enable-pic --enable-postproc --enable-r untime-cpudetect --enable-shared --enable-swresample --enable-vdpau --enable-ver sion3 --enable-x11grab
libavutil 52. 38.100 / 52. 38.100
libavcodec 55. 18.102 / 55. 18.102
libavformat 55. 12.100 / 55. 12.100
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 79.101 / 3. 79.101
libavresample 1. 1. 0 / 1. 1. 0
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 3.100 / 52. 3.100
[rtp @ 0x4fc80] Guessing on RTP content - if not received properly you need an S DP file describing it
Input #0, rtp, from 'rtp://224.1.2.3:1234':
Duration: N/A, start: 0.000000, bitrate: 192 kb/s
Stream #0:0: Audio: mp2, 48000 Hz, mono, s16p, 192 kb/s
Output #0, alsa, to 'default':
Metadata:
encoder : Lavf55.12.100
Stream #0:0: Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mp2 -> pcm_s16le)
Press [q] to stop, [?] for help
size=N/A time=00:00:16.22 bitrate=N/A

')


This is the output when connected to USB wireless adapter:
$this->bbcode_second_pass_code('', '
[root@alarm media]# ffmpeg -i rtp://224.1.2.3:1234 -f alsa default
ffmpeg version 2.0.1 Copyright (c) 2000-2013 the FFmpeg developers
built on Aug 11 2013 09:58:44 with gcc 4.7.2 (GCC)
configuration: --prefix=/usr --disable-debug --disable-static --enable-avresample --enable-dxva2 --enable-fontconfig --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-pic --enable-postproc --enable-runtime-cpudetect --enable-shared --enable-swresample --enable-vdpau --enable-version3 --enable-x11grab
libavutil 52. 38.100 / 52. 38.100
libavcodec 55. 18.102 / 55. 18.102
libavformat 55. 12.100 / 55. 12.100
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 79.101 / 3. 79.101
libavresample 1. 1. 0 / 1. 1. 0
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 3.100 / 52. 3.100
')
permitivity
 
Posts: 141
Joined: Mon Feb 18, 2013 3:08 am

Next

Return to User Questions

Who is online

Users browsing this forum: No registered users and 3 guests