-
Notifications
You must be signed in to change notification settings - Fork 431
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
raspberry pi i2s-mems S32_LE still reported as S16_BE by vlc stream with repeating noise #94
Comments
Hi, |
Updated:2018-05-10
Furthermore I've also tested virtualmic input with alsa file input using a ffmpeg transcoded raw pcm file instead of the raspberry i2s microphone to rule out hardware problems. Tested multiple file formats as alsa sources both 16bitLE/BE and 32bitLE/BE I noticed that the 32bit examples streamed via v4l2rtspserver with the same interrupting/stuttering/gaps as the i2smems, however it sounded like recognizeable music/sound instead of white/buzz noise. Altering the the payload identification from 16>32bit sounds may indeed bring that fix. If specified correctly the 32LE and 32BE examples files sound the same, so I guess the LE>BE is done right, except for the stuttering that indeed maybe RTP payload identifaction related. Since the S32_LE to S32_BE conversion doesn't seem the problem, the noise thing with i2s mems might be because of its fake 32bit (padded 16/24 bit) signal.
Add the following code to your
Create some raw pcm music sources with
Test
After commit 41589c8 there is no recognizable sound or audio stream info in VLC when using S32 except 32LE without no format specifying creates slow/offpitch music. Others 32bit options crash VLC! |
Run "apt-get install ladspa-sdk", then create a /etc/asound.conf file containing the following;
Then you can happily run this and it will work nicely;
There are actually a couple of problems with that microphone (I got a couple of them in the mail last night, and have been fiddling with it all day to make it work nice, much to the annoyance of my wife...)
The above asound.conf solves both problems. The high pass filter (I didn't specify the cutoff, which defaults to 440 Hz) handles the DC offset, and the amp_mono adds a gain of 30 dB. |
Thanks @lbdroid for your comprehensive input for both covering the volume-bug and streaming solution, I will test this solution asap. About the highpass filter, I will be using it to record bird chirps/activity in house so I need to test if it needs adjustment, but I guess lowpass may also be an option now like humm/buzz generator/contruction works?. Do you happen to have a compressed alsa/ffmpeg solution for audio, since v4l2 can also handle compressed/uncompressed formats maybe alsa can do something like 64Kb mono aac? |
Low pass will not be an option. The high pass algorithm "sees" a DC offset as an oscillation of low frequency. Such a low frequency that one cycle is longer than the entire length of the audio. You probably could lower the frequency or play around with it, but honestly, I doubt you'll need to. I've never heard a bird that chirps under 440 Hz. I've been running mine in the house with kids running around making noise, and at 440 Hz, it seems to pick up everything. If you happen to have a subway running under your house, it will probably filter that out. I have not looked into compressing the audio, but I am almost positive that that would have to be done within v4l2rtspstreamer rather than in alsa. |
@lbdroid thanks I verified your workaround. @mpromonet I added virtual alsa file source examples that show different behaviour depending on 16/32 le/be sources and specifying format or relying on default behaviour. Notice the slow offpitch music when S32LE gets default/auto interpreted as S16LE. When using newer/latest commit 41589c8 the 32bit samples with specifying format just crash VLC, although notice that 32LE without format still produces slow/offpitch music. |
Do you also encounter a/v sync/drift issues? In less than half an hour its already more than a few seconds? I'm running on a Pi zero with v2 cam noir, using the v4l2 driver not the uvl4 prop thing. I'm sure its not the client, since restarting vlc client on the same or other machine on the network has the same audio delay. Restarting the server does resync the audio, until it drifts again... |
I haven't noticed any drift, but I'm not running exactly this setup, I have another couple of stages in between where I read the audio from 'lp' with a custom program that analyzes the audio for certain patterns in order to generate notifications, and then writes it out to aloop. I have v4l2rtspserver read the audio from the other side of aloop. If your a/v is going out of sync, it could be that you are running too long of buffers. |
Could you hint where to address these buffer settings as in v4l2/alsa/v4l2rtspserver? I'm mostly running a headless default Raspbian Lite 4.14 image from 2018-04-18 on a rpi0 with 512MB RAM and 128MB for GPU with a v2 noIR camera with v4l2 driver. However the rpi0 does has some other gpio pins active/solderd for sensors DS18b20/DHT11/TCRT5000 although they are not actively being polled by any software right now. The tcrt5000 works without overlay changes using tracking pin11. Maybe these sensors interfere with video&audio recording?
In the following days I hope I have a more comprehensive instruction to replicate symptoms. |
Buffers would be addressed in;
|
Use of other pins should be no issue as long as you aren't trying to use any pin for multiple purposes simultaneously. |
Updated:2018-05-10
On a raspbery pi zero with "i2s mems" mono microphone on raspbian lite strech I'm able to record hearable sound using:
arecord -D plughw:0 -c1 -r 48000 -f S32_LE -t wav -V mono -v recordS32_LE.wav
Although a S16_LE flag is accepted it will not record any sound than, it will also not error so S16_LE is not an option... Further investigation shows that the i2s mems microphone doesn't produce a clean S32 signal but somehow padded 24bit to 32bit signal, this might explain the white noise sound when used v4l2rtspserver.
When trying to run "v4l2server" (compiled with alsa support) to stream video and audio I tried with the following command but gives interrupted/repeated noise/hiss every second without recognizable sound in vlc player:
Omiting
-C 1
for single channel gives error:Changing S32_LE to S16_LE still shows S16_BE in vlc stream info but without hearable sound or continuous interrupted noise.
I read that earlier fixes enabled S16_LE to S16_BE conversion and later S32_LE to S32_BE conversion by your server and pull request #55 also does some audio fixes.
Could it be that S32_LE to BE is broken?Further testing with a music file based virtual alsa input device shows that S32_LE to S32_BE conversion is done right and is not broken, however mpromonet mentions it is the rtp payload that still shows S16 when S32 is used. Changes in commit 41589c8 didn't fix this for me yet.Github user @lbdroid posted a usable workaround which even creates a single channel mono signal
-C 1
when needed. YMMV depending on the amount of sound adapters I had the change"plughw:1,0"
into"plughw:0,0"
before it started working.The text was updated successfully, but these errors were encountered: