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 support pcm_s16le audio #523

Closed
gtxaspec opened this issue Jul 13, 2023 · 11 comments
Closed

Add support pcm_s16le audio #523

gtxaspec opened this issue Jul 13, 2023 · 11 comments
Labels
enhancement New feature or request
Milestone

Comments

@gtxaspec
Copy link

gtxaspec commented Jul 13, 2023

in go2rtc, currently supported is pcm_s16be, can support for pcm_s16le included as well? this would help compatability with certain wyze cameras which use pcm_s16le

@AlexxIT AlexxIT added the question Further information is requested label Jul 14, 2023
@AlexxIT
Copy link
Owner

AlexxIT commented Jul 14, 2023

Can you provide more info how you pass this data to go2rtc?
I'm not sure that pcm_s16be was right choose. And maybe pcm_s16le more common standard.

@gtxaspec
Copy link
Author

gtxaspec commented Jul 15, 2023

we are capturing the audio from alsa which is in pcm_s16le format, then we:

exec:ffmpeg -hide_banner -f alsa -ac 1 -i hw:0,0 -c:a copy -f rtsp {output} to go2rtc`

...obviously s16le doesn't work at the moment but this is how we would do it.

Also, if I remember correctly, LPCM in MOV container is always big-endian? It could be better to support both

@AlexxIT
Copy link
Owner

AlexxIT commented Jul 15, 2023

Can you enable trace logs for rtsp module? I need to check SDP part from FFmpeg.

@AlexxIT
Copy link
Owner

AlexxIT commented Jul 15, 2023

FFmpeg + RTSP + pcm_s16le has a problem. FFmpeg doesn't pass info about codec name and params...
I can see you set only one channel for your camera. Please check what the default sample rate:

ffmpeg -hide_banner -f alsa -ac 1 -i hw:0,0 -c:a copy -f null -

@gtxaspec
Copy link
Author

gtxaspec commented Jul 15, 2023

@AlexxIT Camera can provide 16000 or 8000 depending on alsa device hw:0,0 or hw:2,0:

[root@WCV3:~]# ffmpeg -hide_banner -f alsa -ac 1 -i hw:0,0 -c:a copy -f null -
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, alsa, from 'hw:0,0':
  Duration: N/A, start: 1689415357.800710, bitrate: 256 kb/s
  Stream #0:0: Audio: pcm_s16le, 16000 Hz, mono, s16, 256 kb/s
[NULL @ 0x775fc040] Requested output format 'null' is not a suitable output format
pipe:: Invalid argument
[root@WCV3:~]# ffmpeg -hide_banner -f alsa -ac 1 -i hw:2,0 -c:a copy -f null -
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, alsa, from 'hw:2,0':
  Duration: N/A, start: 1689415421.555271, bitrate: 128 kb/s
  Stream #0:0: Audio: pcm_s16le, 8000 Hz, mono, s16, 128 kb/s
[NULL @ 0x77dcf040] Requested output format 'null' is not a suitable output format
pipe:: Invalid argument
[root@WCV3:~]# 

@AlexxIT
Copy link
Owner

AlexxIT commented Jul 15, 2023

OK. Looks like I can detect codec based on bitrate. It always constant for specific sample rate + channels settings.

pcm_s16be, 44100 Hz, stereo => 10
pcm_s16be, 48000 Hz, stereo => 96 L16/48000/2
pcm_s16be, 44100 Hz, mono   => 11

pcm_s16le, 48000 Hz, stereo => 96 (b=AS:1536)
pcm_s16le, 44100 Hz, stereo => 96 (b=AS:1411)
pcm_s16le, 16000 Hz, stereo => 96 (b=AS:512)
pcm_s16le, 8000 Hz, stereo  => 96 (b=AS:256)

pcm_s16le, 48000 Hz, mono   => 96 (b=AS:768)
pcm_s16le, 44100 Hz, mono   => 96 (b=AS:705)
pcm_s16le, 16000 Hz, mono   => 96 (b=AS:256)
pcm_s16le, 8000 Hz, mono    => 96 (b=AS:128)

@AlexxIT
Copy link
Owner

AlexxIT commented Jul 15, 2023

OK. You can try latest master version. Do you need binary or you can build it yourself?

@AlexxIT AlexxIT added enhancement New feature or request and removed question Further information is requested labels Jul 15, 2023
@AlexxIT AlexxIT changed the title support pcm_s16le Add support pcm_s16le audio Jul 15, 2023
@gtxaspec
Copy link
Author

If you can provide mipsle binary I can test

@AlexxIT
Copy link
Owner

AlexxIT commented Jul 16, 2023

go2rtc_linux_mipsel.zip

@gtxaspec
Copy link
Author

@AlexxIT confirmed working!

@AlexxIT AlexxIT added this to the v1.6.1 milestone Jul 20, 2023
@AlexxIT
Copy link
Owner

AlexxIT commented Jul 20, 2023

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

No branches or pull requests

2 participants