Closed dbuezas closed 1 year ago
we had a lot of trouble getting an ffmpeg build that works for all setups, I wouldn't count on finding a new distribution to support this. If you run frigate in native docker you can already run whatever ffmpeg binary that you want, overriding the internal binary.
I see. Thank you for your support. I'm running Frigate as an AddOn in HomeAssistant OS, to apply your suggestion I thought of cloning this repo and copying the frigate folder to my local ones to then modify the dockerfile, but there's no docker file. Do you have a tip I could apply to replace the ffmpeg binary? I already copied the one I get when I ssh into my HA instance to the config folder so I can grab it from there later
the only docker file is the one in the main frigate repo. Like I said there is no official way to do this with the addon
Ok, I tried something different. I downloaded the prelinked ffmpeg executable from their official page, put it in /config, bash'd myself into the frigate's docker container and executed it from there.
./ffmpeg -hide_banner -f alsa -ac 1 -i default -c:a libmp3lame -ar:a 24000 -ac:a 1 output.mp3
ALSA lib ../../src/confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib ../../src/conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib ../../src/confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib ../../src/conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib ../../src/confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib ../../src/conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib ../../src/conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib ../../../src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default
[alsa @ 0x70158c0] cannot open audio device default (No such file or directory)
default: Input/output error
Now it has alsa, but no access to the hw device within the container. I guess I'll need to make a local addon with a modified dockerfile anyway.
Closing the ticket, as you already answered my original enquiry. Thanks again.
Hi again! I made my own small local addon with these:
RUN apk add --no-cache \
alsa-plugins-pulse=1.2.7.1-r0 \
alsa-utils=1.2.8-r0 \
pulseaudio-utils=16.1-r6 \
ffmpeg
And added these to the config.yaml
audio: true
video: true
With these, I'm able to stream my microphone's audio via ffmpeg.
Would you consider adding that to frigate so this becomes possible without my ugly hack?
Thanks!
Frigate doesn't use alpine as a base, so this isn't a very helpful proof of concept.
Oh, I didn't realise this. The author of go2rtc seems interested in this, and that project does use alpine so maybe it lands there. https://github.com/AlexxIT/go2rtc/issues/385#issuecomment-1529399420
If anyone else needs this, the best solution to stream the microphone at the moment is to use the standalone go2rtc addon instead of the one built in in frigate. The author of go2rtc just added alsa support in v1.5.0. Example for my webcam:
streams:
webcam_video:
- ffmpeg:device?video=/dev/video2&input_format=mjpeg&video_size=1920x1080#video=h264#hardware
webcam:
- ffmpeg:webcam_video#video=copy
- exec:ffmpeg -f alsa -ac 1 -i default -c:a libopus -ar:a 16000 -ac:a 1 -af adelay=0ms -rtsp_transport tcp -f rtsp {output}
Then hookup frigate detection to webcam_video
. This means audio encoding for the microphone won't run unnecessarily, which saves some cpu
I'm trying to add the audio stream from the computer's microphone to a webcam and it looks like the ffmpeg in this docker container doesn't understand alsa.
This command works perfectly if I run it from ssh, so the microphone does work fine.
ffmpeg -hide_banner -f alsa -ac 1 -i default -c:a libmp3lame -ar:a 24000 -ac:a 1 output.mp3
Here's my intended config:
I asked in go2rtc first: https://github.com/AlexxIT/go2rtc/issues/385, where I see other people using alsa successfully in the issue section.
Asking here now since I learned that frigate only uses the go2rtc binary, so it would be the docker file of frigate that would need a version of ffmpeg with alsa suport.
Would you consider adding an ffmpeg with alsa suport in the future? Thank you!