rpicam-apps
rpicam-apps copied to clipboard
[Feature] Allow control of audio capture sample rate
For now, the sample rate (Hz) of captured audio is not editable by command line option, as noted in https://forums.raspberrypi.com/viewtopic.php?t=333940
It'd be useful to have that audio, e.g. to lower the rate for performance/memory considerations :)
This was always in the plan - just ran out of time to implement it.
I'll look to pick it up again when I get the time.
Turns out I had already written pretty much all of the code, expect exposing a command line argument. https://github.com/raspberrypi/libcamera-apps/pull/390 seems like a plausible change to get this working. Would you be able to test this out?
Thanks,
I checked out your branch and built it like noted here : https://www.raspberrypi.com/documentation/accessories/camera.html#building-libcamera-apps
But these custom apps don't support any of the libav-related CLI options :
pi@raspberrypi:~/licamera_naushir/build $ libcamera-vid --timeout 15000 --nopreview --output file.mp4 --codec libav --libav-audio
Closing Libcamera application(frames displayed 0, dropped 0)
Camera stopped!
Tearing down requests, buffers and configuration
Camera closed
ERROR: *** unrecognised option '--libav-audio' ***
I guess i'm missing some dependencies and/or cmake flags, is there somewhere some info on how to build a feature-complete libcamara-apps please?
You need to ensure the libav libraries are installed on your system before building libcamera-apps. Otherwise the libav code will not get linked it.
I'll try to get an official release pushed to apt as soon as this gets merged.
Ok so in case it helps anybody, this required installing libavcodec-dev, libavutil-dev, libavformat-dev and libavdevice-dev with apt under Raspberry Pi OS ^^'
I've tested the new parameter on newly compiled executable :
./libcamera-vid --timeout 30000 --nopreview --output file.mp4 --codec libav --libav-audio --audio-samplerate 16000
It seems to work fine :)
Thanks for confirming. The change will make it into apt very soon.
I'll close this issue down now.