abarisain / dmix

A modern MPD Client for Android.
Apache License 2.0
590 stars 205 forks source link

mpdroid can't stream vorbis streams #807

Open anarcat opened 8 years ago

anarcat commented 8 years ago

I know there has been numerous reports similar to this one (e.g. #643, #60) but all of those are closed, and I still believe there is a bug here in the current version, downloaded from F-Droid (running on CM 12.1-nightlies).

I have this configuration in mpd.conf:

audio_output {
        type            "httpd"
        name            "My HTTP Stream"
        #encoder                "lame"          # optional, vorbis or lame
        encoder         "vorbis"                # optional, vorbis or lame
        port            "8000"
        bind_to_address "0.0.0.0"               # optional, IPv4 or IPv6
        quality         "5.0"                   # do not define if bitrate is defined
        #bitrate                "128"                   # do not define if quality is defined
        format          "44100:16:2"
        max_clients     "3"                     # optional 0=no limit
}

I tried lame as an ecoder: that works. vorbis gives me those errors in logcat:

D/MPDroidService( 8193): Received message: StreamHandler.START
D/NuPlayerDriver( 1363): reset(0xb86b1708)
E/IMediaHTTPConnection( 1363): requested 8918, got 4294967295
I/NuCachedSource2( 1363): caching reached eos.
D/NuPlayerDriver( 1363): notifyResetComplete(0xb86b1708)
D/NuPlayerDriver( 1363): reset(0xb86b1708)
E/FFMPEG  ( 1363): FFSource getSize failed
E/FFMPEG  ( 1363): FFSource getSize failed
E/FFMPEG  ( 1363): FFSource getSize failed
I/FFMPEG  ( 1363): Input #0, ogg, from 'android-source:0xb86b15a0':
I/FFMPEG  ( 1363):   Duration: 00:00:49.02, start: 42.964172, bitrate: N/A
I/FFMPEG  ( 1363):     Stream #0:0: Audio: vorbis, 44100 Hz, stereo, fltp, 160 kb/s
I/FFMPEG  ( 1363):     Metadata:
I/FFMPEG  ( 1363):       ARTIST          : Extinction of Mankind
I/FFMPEG  ( 1363):       TITLE           : Harvest of discontent
I/FFMPEG  ( 1363):       ALBUM           : Baptised in shit
I/FFMPEG  ( 1363):       TRACK           : 01
I/FFMPEG  ( 1363):       GENRE           : Crust
D/FFmpegExtractor( 1363): FFmpegExtrator, url: android-source:0xb86b15a0, format_name: ogg, format_long_name: Ogg
I/FFmpegExtractor( 1363): adjust mime(application/ogg -> audio/vorbis)
D/FFmpegExtractor( 1363): suppoted codec(vorbis) by official Stagefright
D/FFmpegExtractor( 1363): ffmpeg detected media content as 'audio/vorbis' with confidence 0.08
D/ExtendedUtils( 1363): Try creating ExtendedExtractor
E/ExtendedExtractor( 1363): Failed to instantiate extractor
D/ExtendedUtils( 1363): Couldn't create the extended extractor, return default one
I/FFmpegExtractor( 1363): android-source:0xb86b15a0
E/FFmpegExtractor( 1363): android-source:0xb86b15a0: avformat_open_input failed, err:Unknown error 1011
W/FFmpegExtractor( 1363): sniff through BetterSniffFFMPEG failed, try LegacySniffFFMPEG
E/FFmpegExtractor( 1363): android-source:0xb86b15a0|file:http://radio.anarc.at:8000/: avformat_open_input failed, err:Unknown error 1011
D/FFmpegExtractor( 1363): SniffFFMPEG failed to sniff this source
E/GenericSource( 1363): Failed to init from data source!
W/InputEventReceiver( 8168): Attempted to finish an input event but the input event receiver has already been disposed.
W/InputMethodManagerService( 1617): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@2eaa8f9d attribute=null, token = android.os.BinderProxy@3800fe98
D/StreamHandler( 8193): A stream is already being prepared.
D/MPDroidService( 8193): Received message: StreamHandler.BUFFERING_BEGIN
D/MediaHTTPConnection( 8193): filterOutInternalHeaders: key=User-Agent, val= stagefright/1.2 (Linux;Android 5.1.1)
D/MediaHTTPConnection( 8193): proxy null port 0
I/FFmpegExtractor( 1363): android-source:0xb8591618
E/FFMPEG  ( 1363): FFSource getSize failed

Now, I understand the ogg encoder of MPD might be broken, so I tried something else. I piped that to Icecast, since it's a thing I used to do before anyways (icecast is more stable than the httpd plugin of MPD, in my experience):

audio_output {
       type            "shout"
       name            "Currently listening to..."
       host            "localhost"
       port            "8000"
       mount           "/radio.ogg"
       password        "hackme"
       quality         "4.0"
       format          "44100:16:2"
}

One interesting bit is that I had to change the suffix at that point. For that to take effect, I had to restart mpdroid multiple times, because the change wouldn't "stick": the setting would show up in the Default connection settings when i would edit it, but it would keep on contacting the old server URL without a suffix. That was a little frustrating.

Long story short, Icecast didn't solve the problem, I get similar errors from ffmpeg in logcat.

I can obviously play both streams fine in Linux using ffmpeg, mplayer, vlc or ogg123.

Encoding with lame works, but doesn't work with Icecast (which supports only ogg containers, iirc). I am not sure why.

anarcat commented 8 years ago

It seems like a common problem that Android cannot play ogg streams correctly. Here's a library that seems to implement that correctly:

https://github.com/radzio/AndroidOggStreamPlayer

abarisain commented 8 years ago

Streaming has always been hit/miss with Android sadly.

What's even sadder is that over the years, cyanogen introduced MUCH more breakage to this audio mess, so traditionally, streaming has always been worse on CM than AOSP :/