Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add audio from USB microphone #1

Open
lestrozi opened this issue Oct 21, 2021 · 3 comments
Open

Add audio from USB microphone #1

lestrozi opened this issue Oct 21, 2021 · 3 comments

Comments

@lestrozi
Copy link

Great project! Any chance of adding audio from the USB microphone when creating the mp4 frames? If you have some pointers on how to do that I can do some coding and submit a PR.

@soyersoyer
Copy link
Owner

Thanks!
I am not very experienced in audio, but adding audio from usb seems to a bit complicated. Reading from the microphone maybe easy. We can use alsa with python3-pyalsa. But we have to encode the sound into AAC(-LC) because of the mp4 format. But encoding is a bit hard, because there aren't any decent aac encoder library there. The ffmpeg aac comes inside libavcodec and it is very big. The libfdk_aac is not in the raspbian repository, so the users have to build it, it's not user friendly. Maybe we can use the libvo-aacenc0, but it's not a very good quality codec and there are no python bindings. So we have to write bindings too.
I am working to replace the raspivid with v4l2. After I can dig deeper into this.

@lestrozi
Copy link
Author

TBH I think ffmpeg is the safest bet. Apparently some people can combine video and audio piping raspivid to ffmpeg -i - -f alsa -ac 1 -i hw:0,0 -map 0:0 -map 1:0 -vcodec copy -acodec aac. I recently ordered a USB microphone and will play a bit with it when it arrives :)

@spookyfirehorse
Copy link

spookyfirehorse commented May 3, 2022

Hi !

great work

yess please add audio

for me is opus the best choise. it is in the ffmpeg and has better performance than libfdk

-c:a libopus -application lowdelay -b:a 32k -movflags +faststart -async 1

and sorry but is it possible to be come an option for rtsp streaming ?

can you tell me how i can do that for my own to add audio and rtsp in your files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants