For using a Pi as a baby monitor I wanted to add audio from an USB soundcard to the stream and ran into some difficulties.
The used version of ffmpeg seems not to support audio from alsa.
This may be fixed by editing some dependencies in the build configuration, but I was too lazy to find out and ffmpeg would possibly needed recompilation, so I found a different solution.
It requires the installation of the oss-compat package to get the dsp(1) device:
Then, this commandline should work:
Code: Select all
raspivid -t 0 -fps 25 -ex auto -b 500000 -o - | ffmpeg -f oss -ac 1 -ar 44100 -i /dev/dsp1 -i - -vcodec copy -f flv -metadata streamName=myStream tcp://0.0.0.0:6666
I needed some time to find out what the -an switch means
but after removing it finally worked.
There may be more or less of "Non-monotonous DTS in output stream" errors after starting the stream, this seems to depend on the choosen resolution of the camera and/or framerate. But after a second they are gone and the stream is stable.
There are some problems left: In the -ex night exposure mode the framerate drops to 5-6fps and ffmpeg seems to have problems to mux the audio into a stream with such a low framerate.
Does somebody know how to fix this?
Is there a more compatible output stream format available?
It works fine in browsers on windows but my android smartphone seems not to be able to display this flv. I tried 4 or 5 different players on the phone, none of them worked.