Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

libvlc Android: unable to play HTTP network streams

I'm currently facing an issue trying to play network stream using VLC for Android.

I have basically followed this guide, https://wiki.videolan.org/AndroidCompile/, cloned the repo and built: everything works fine, I can run my application and play videos (locally or from the network).

Then I took the libvlc AAR and created a new Android project from scratch: I'm able to play local videos but when I pass in a URL the stream is not opened.

Relevant code:

// Create LibVLC
ArrayList<String> options = new ArrayList<String>();
options.add("--aout=opensles");
options.add("--audio-time-stretch"); // time stretching
options.add("-vvv"); // verbosity
libvlc = new LibVLC(options);
holder.setKeepScreenOn(true);

// Create media player
mMediaPlayer = new MediaPlayer(libvlc);
mMediaPlayer.setEventListener(mPlayerListener);

// Set up video output
final IVLCVout vout = mMediaPlayer.getVLCVout();
vout.setVideoView(mSurface);
vout.addCallback(this);
vout.attachViews();

Media m = new Media(libvlc, Uri.parse(media));
mMediaPlayer.setMedia(m);
mMediaPlayer.play();

Where media is a String for the URL.

Is it something missing in my configuration (i.e. modules)?

Here's the log I get:

D/LibVLCAndroidSample: Playing back http://jell.yfish.us/media/jellyfish-3-mbps-hd-h264.mkv
D/Activity: performCreate Call Injection manager
I/InjectionManager: dispatchOnViewCreated > Target : com.compdigitec.libvlcandroidsample.VideoActivity isFragment :false
D/VLC: [ede46778/0] core libvlc: VLC media player - 3.0.0-git Vetinari
D/VLC: [ede46778/5f726f74] core libvlc: Copyright © 1996-2016 the VideoLAN team
D/VLC: [ede46778/190019] core libvlc: revision 2.2.0-git-7900-g640a891
D/VLC: [ede46778/190019] core libvlc: configured with ../configure  '--host=arm-linux-androideabi' '--build=x86_64-unknown-linux' '--enable-neon' '--disable-nls' '--enable-live555' '--enable-realrtsp' '--enable-avformat' '--enable-swscale' '--enable-avcodec' '--enable-opus' '--enable-opensles' '--enable-mkv' '--enable-taglib' '--enable-dvbpsi' '--disable-vlc' '--disable-shared' '--disable-update-check' '--disable-vlm' '--disable-dbus' '--enable-lua' '--disable-vcd' '--disable-v4l2' '--disable-gnomevfs' '--enable-dvdread' '--enable-dvdnav' '--disable-bluray' '--disable-linsys' '--disable-decklink' '--disable-libva' '--disable-dv1394' '--enable-mod' '--disable-sid' '--disable-gme' '--disable-tremor' '--enable-mad' '--disable-dca' '--disable-sdl-image' '--enable-zvbi' '--disable-fluidsynth' '--disable-jack' '--disable-pulse' '--disable-alsa' '--disable-samplerate' '--disable-sdl' '--disable-xcb' '--disable-atmo' '--disable-qt' '--disable-skins2' '--disable-mtp' '--disable-notify' '--enable-libass' '--disable-svg' '--d
D/VLC: [ede46778/eb81c760] core libvlc: plug-ins loaded: 275 modules
D/VLC: [ee93d168/eb81c760] core logger: looking for logger module matching "any": 4 candidates
D/VLC: [ee93d168/10001] core logger: using logger module "android_logger"
D/VLC: [ede46778/2a98] core libvlc: translation test: code is "C"
D/VLC: [ee93d1c8/2a98] core keystore: looking for keystore module matching "memory": 3 candidates
D/VLC: [ee93d1c8/2a98] core keystore: using keystore module "memory"
D/VLC: [ede46778/2a98] core libvlc: CPU has capabilities ARM_NEON FPU 
D/VLC: [ede472d8/2a98] core generic: creating audio output
D/VLC: [f4e4bda8/2a98] core audio output: looking for audio output module matching "opensles": 4 candidates
W/libOpenSLES: class OutputMix interface 0 requested but unavailable MPH=43
D/VLC: [f4e4bda8/2a98] core audio output: using audio output module "opensles_android"
D/VLC: [ede472d8/2a98] core generic: keeping audio output
D/SecWifiDisplayUtil: Metadata value : SecSettings2
D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{22a16c1 I.E...... R.....ID 0,0-0,0}
D/mali_winsys: new_window_surface returns 0x3000,  [1440x2560]-format:1
D/VLC: [ee923df8/2a98] core input: Creating an input for 'jellyfish-3-mbps-hd-h264.mkv'
D/VLC: [ee923df8/2dbb] core input: using timeshift granularity of 50 MiB
D/VLC: [ee923df8/2dbb] core input: using default timeshift path
D/VLC: [ee923df8/2dbb] core input: `http://jell.yfish.us/media/jellyfish-3-mbps-hd-h264.mkv' gives access `http' demux `' path `jell.yfish.us/media/jellyfish-3-mbps-hd-h264.mkv'
D/VLC: [f4ebbbc8/2dbb] core input source: specified demux: any
D/VLC: [f4ebbbc8/2dbb] core input source: creating demux: access='http' demux='any' location='jell.yfish.us/media/jellyfish-3-mbps-hd-h264.mkv' file='(null)'
D/VLC: [ee93be28/2dbb] core demux: looking for access_demux module matching "http": 6 candidates
D/VLC: [ee93be28/2dbb] core demux: no access_demux modules matched
D/VLC: [ee93bea8/2dbb] core access: creating access: http://jell.yfish.us/media/jellyfish-3-mbps-hd-h264.mkv
D/VLC: [ee93bea8/2dbb] core access: looking for access module matching "http": 22 candidates
D/VLC: [ee93bea8/2dbc] transport access: resolving jell.yfish.us ...
E/VLC: [ee93bea8/2dbc] transport access: cannot resolve jell.yfish.us port 80: No address associated with hostname
E/VLC: [ee93bea8/2dbb] access access: HTTP connection failure
D/VLC: [ee93bea8/2dbb] http access: querying proxy for http://jell.yfish.us/media/jellyfish-3-mbps-hd-h264.mkv
D/VLC: [ee93bea8/2dbb] http access: no proxy
D/VLC: [ee93bea8/2dbb] http access: http: server='jell.yfish.us' port=80 file='/media/jellyfish-3-mbps-hd-h264.mkv'
D/VLC: [ee93bea8/2dbb] core access: net: connecting to jell.yfish.us port 80
E/VLC: [ee93bea8/2dbb] core access: cannot resolve jell.yfish.us port 80 : No address associated with hostname
E/VLC: [ee93bea8/2dbb] http access: cannot connect to jell.yfish.us:80
D/VLC: [ee93bea8/2dbb] core access: no access modules matched
E/VLC: [f4ebbbc8/2dbb] core input source: cannot access http://jell.yfish.us/media/jellyfish-3-mbps-hd-h264.mkv
E/VLC: [ee923df8/2dbb] core input: Your input can't be opened
E/VLC: [ee923df8/2dbb] core input: VLC is unable to open the MRL 'http://jell.yfish.us/media/jellyfish-3-mbps-hd-h264.mkv'. Check the log for details.
like image 399
fasteque Avatar asked Jun 22 '16 12:06

fasteque


1 Answers

After digging a bit in the libvlc code, I realized the cause of the issue was really simple and I'm actually not that happy I didn't think about it before.

Anyway I post the answer for anyone who faces the same issue and starts to dig into libvlc before checking the most obvious thing.

Basically I was missing the INTERNET permission in the manifest:

<uses-permission android:name="android.permission.INTERNET" />

The logs are not quite clear, specially on Android side, probably because the rendering is not done in the UI thread, so you don't get the usual NetworkOnMainThreadException.

like image 112
fasteque Avatar answered Oct 24 '22 07:10

fasteque