Playing raw audio pcm stream has knocking noise. Same stream plays fine on android.
Summary
What I have: A raw audio pcm stream. I plug it into VLC by implementing my own MediaInput
. (I can keep the code shared for Android and iOS then)
Options I'm using:
Media audioMedia = new Media(LibVLC, audioMediaInput); // audioMediaInput is implementation of MediaInput
audioMedia.AddOption(":demux=rawaud");
audioMedia.AddOption(":rawaud-channels=1");
audioMedia.AddOption(":rawaud-samplerate=8000");
audioMedia.AddOption(":mono");
The options above are enough that the stream plays fine on Android. On iOS, with the same options, I hear a knocking noise. (Knocking or real fast tapping)
Minimal project and steps to reproduce
I don't have the rights to share the code here, but I was hoping the logs might inform someone of something. Maybe a direction I can go looking in.
What is the current bug behavior?
Knocking/Tapping noise on iOS. Plays fine on Android.
What is the expected correct behavior?
Stream should play fine on iOS. With the same options, as it does on android.
Does it work on other plaforms? Does it work with the official VLC apps?
Yes, it works fine on Android.
Relevant logs and/or screenshots
libvlc Debug: using access module "imem_access"
Thread started: #16
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: using 16777216 bytes buffer, 16777216 bytes read
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: looking for stream_filter module matching "prefetch,cache_read": 25 candidates
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: looking for stream_filter module matching "any": 25 candidates
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: using stream_filter module "prefetch"
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: no stream_filter modules matched
Thread started: <Thread Pool> #17
libvlc Debug: attachment of directory-extractor failed for imem://
Thread started: #18
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: format initialized: channels=1 , samplerate=8000 Hz, fourcc=s16l, bits per sample = 16, bitrate = 128000 bit/s
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: selecting program id=0
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: elementary stream added
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: frame size is 800 bytes
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: using demux module "rawaud"
LibVLCSharp.Shared.MediaPlayer
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: looking for audio decoder module matching "any": 16 candidates
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: using audio decoder module "araw"
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: looking for meta reader module matching "any": 1 candidates
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: no meta reader modules matched
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: `imem://' successfully opened
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: Buffering 0%
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: Buffering 16%
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: Buffering 33%
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: reusing audio output
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: VLC is looking for: 's16l' 8000 Hz Mono frame=1 samples/2 bytes
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: looking for stream_directory module matching "any": 1 candidates
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: using stream_filter module "record"
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: no stream_directory modules matched
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: creating demux: access='imem' demux='rawaud' location='' file='(null)'
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: looking for stream_filter module matching "record": 25 candidates
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: samplerate:8000Hz channels:1 bits/sample:16
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: looking for demux module matching "rawaud": 46 candidates
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: Buffering 50%
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: Buffering 66%
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: Output on Default, channel count: 2
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: Current device has a latency of 8041 us
Thread started: <Thread Pool> #19
Thread started: <Thread Pool> #20
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: VLC will output: Stereo
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: selected 2 physical channels for device output
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: Current AU format: [8000.000000][mcpl][9][8][1][8][2][32]
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: not output layout, default to Stereo
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: analog AudioUnit output successfully opened for f32l Stereo
Thread started: <Thread Pool> #21
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: conversion: 's16l'->'f32l' 8000 Hz->8000 Hz Mono->Mono
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: looking for audio converter module matching "any": 7 candidates
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: s16l->f32l, bits per sample: 16->32
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: using audio converter module "audio_format"
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: conversion pipeline complete
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: conversion: 'f32l'->'f32l' 8000 Hz->8000 Hz Mono->Stereo
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: looking for audio converter module matching "any": 7 candidates
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: using audio converter module "trivial"
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: conversion pipeline complete
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: looking for audio resampler module matching "any": 2 candidates
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: using audio resampler module "ugly"
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: 1.000 scale, 240.000 stride_in, 240 stride_out, 192 standing, 48 overlap, 112 search, 400 queue, fl32 mode
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: output 'f32l' 8000 Hz Stereo frame=1 samples/8 bytes
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: params: 30 stride, 0.200 overlap, 14 search
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: looking for audio volume module matching "any": 2 candidates
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: input 's16l' 8000 Hz Mono frame=1 samples/2 bytes
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: looking for audio filter module matching "scaletempo": 13 candidates
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: using audio volume module "float_mixer"
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: using audio filter module "scaletempo"
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: format: 8000 rate, 1 nch, 4 bps, fl32
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: Buffering 83%
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: Buffering 100%
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: Stream buffering done (350 ms in 252 ms)
LibVLCSharp.Shared.MediaPlayer
libvlc Debug: Decoder wait done in 0 ms
Environment
- OS: iOS
- Version 14.3
- Device: iPhone 8
- LibVLC version and architecture: VideoLAN.LibVLC.iOS 3.3.10
- LibVLCSharp version: LibVLCSharp.Forms 3.4.8
Possible fixes
I have spoken to people who used to dabble in audio, and they think it might be an issue with the audio buffer on iOS. I couldn't find any options that I set that fixed my issue.Samplerate8000_iOS