Problem using LibVLC

VLC for Android and Chrome OS specific usage questions
Fradow
Blank Cone
Blank Cone
Posts: 22
Joined: 10 Jan 2014 17:44

Problem using LibVLC

Postby Fradow » 10 Jan 2014 18:09

Hello,

I am having some problems using LibVLC, here is the error I get when trying to play a video (the first 3 lines and the last are errors, there is a lot of logs before) :

Code: Select all

01-10 18:29:00.524: E/VLC(11998): core vout display: Failed to change zoom 01-10 18:29:00.524: E/VLC(11998): core vout display: Failed to set on top 01-10 18:29:00.524: E/VLC(11998): core vout display: Failed to change source AR 01-10 18:29:00.524: D/VLC(11998): core generic: creating audio output 01-10 18:29:00.524: D/VLC(11998): core audio output: looking for audio output module matching "opensles": 4 candidates 01-10 18:29:00.534: W/libOpenSLES(11998): class OutputMix interface 0 requested but unavailable MPH=43 01-10 18:29:00.534: D/VLC(11998): core audio output: using audio output module "opensles_android" 01-10 18:29:00.544: D/VLC(11998): core audio output: output 's16l' 44100 Hz Stereo frame=1 samples/4 bytes 01-10 18:29:00.544: D/VLC(11998): core volume: looking for audio volume module matching "any": 3 candidates 01-10 18:29:00.544: D/VLC(11998): core volume: using audio volume module "integer_mixer" 01-10 18:29:00.544: D/VLC(11998): core audio output: input 'f32l' 44100 Hz Stereo frame=1 samples/8 bytes 01-10 18:29:00.544: D/VLC(11998): core audio output: conversion: 'f32l'->'s16l' 44100 Hz->44100 Hz Stereo->Stereo 01-10 18:29:00.544: D/VLC(11998): core audio converter: looking for audio converter module matching "any": 7 candidates 01-10 18:29:00.544: D/VLC(11998): audio_format audio converter: f32l->s16l, bits per sample: 32->16 01-10 18:29:00.544: D/VLC(11998): core audio converter: using audio converter module "audio_format" 01-10 18:29:00.544: D/VLC(11998): core audio output: conversion pipeline complete 01-10 18:29:00.544: D/VLC(11998): core audio resampler: looking for audio resampler module matching "any": 1 candidates 01-10 18:29:00.544: D/VLC(11998): core audio resampler: using audio resampler module "ugly_resampler" 01-10 18:29:00.544: D/VLC(11998): core decoder: End of audio preroll 01-10 18:29:00.554: D/VLC(11998): core decoder: End of video preroll 01-10 18:29:00.554: D/VLC(11998): core decoder: Received first picture 01-10 18:29:00.554: A/libc(11998): Fatal signal 11 (SIGSEGV) at 0x00000058 (code=1), thread 12047 (company.activity)
I am probably forgetting something, but I can't find what it is.

I get the same error message when trying to use the LibVLC Android Sample here : https://bitbucket.org/edwardcw/libvlc-android-sample

In my project, I am using the libvlcjni.so library and the org.videolan.libvlc package from VLC Beta, which is correctly reading the same video.

Does anyone know what is missing from my code ?

Here is my code, edited for clarity :

Code: Select all

public class MainActivity extends MyCustomizedActivity implements iVideoPlayer { public static FrameLayout mainFrame; public static FrameLayout base; public static SurfaceView videoView; protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); this.runOnUiThread(new Runnable() { @Override public void run() { //NativeUtility.getMainActivity is a way to get MainActivity videoView = new SurfaceView(NativeUtility.getMainActivity()); mainFrame = NativeUtility.getMainActivity().getMainLayout(); //A valid FrameLayout which was initialized in MyCustomizedActivity onCreate base = new FrameLayout(NativeUtility.getMainActivity()); mainFrame.addView(base, 100, 100); base.addView(videoView); SurfaceHolder mSurfaceHolder = videoView.getHolder(); mSurfaceHolder.setFormat(PixelFormat.RGBX_8888); LibVLC vlc = null; try { //LibVLCUtil is essentially the same as org.videolan.vlc.Util, except there is no CrashHandler and the context is MainActivity vlc = LibVLCUtil.getLibVlcInstance(); } catch (LibVlcException e) { e.printStackTrace(); } vlc.attachSurface(videoView.getHolder().getSurface(), NativeUtility.getMainActivity()); MediaList list = new MediaList(vlc); java.io.File file = new java.io.File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Movies/videoplayback.mp4"); file.setReadable(true, false); //This confirms the file exists Log.i("MainActivity", "File exists : " + (file.exists() ? "yes" : "no")); Media m = new Media(vlc, LibVLC.PathToURI(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Movies/videoplayback.mp4")); list.add(m); vlc.setMediaList(list); vlc.playIndex(0); } }); } //This is copied from VideoPlayerHandler changeSurfaceSize() in org.videolan.vlc.gui.videoVideoPlayerActivity.java //I removed a lot of code to avoid setting lots of parameters @Override public void setSurfaceSize(int width, int height, int visible_width, int visible_height, int sar_num, int sar_den) { if (width * height == 0) return; // get screen size int dw = getWindow().getDecorView().getWidth(); int dh = getWindow().getDecorView().getHeight(); // getWindow().getDecorView() doesn't always take orientation into account, we have to correct the values boolean isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; if (dw > dh && isPortrait || dw < dh && !isPortrait) { int d = dw; dw = dh; dh = d; } // sanity check if (dw * dh == 0 || width * height == 0) { Log.e("MainActivity", "Invalid surface size"); return; } // force surface buffer size SurfaceHolder mSurfaceHolder = videoView.getHolder(); mSurfaceHolder.setFixedSize(width, height); // set display size LayoutParams lp = videoView.getLayoutParams(); lp.width = dw * width / visible_width; lp.height = dh * height / visible_height; videoView.setLayoutParams(lp); // set frame size (crop if necessary) lp = base.getLayoutParams(); lp.width = dw; lp.height = dh; base.setLayoutParams(lp); videoView.invalidate(); } }

edwardw
Big Cone-huna
Big Cone-huna
Posts: 2346
Joined: 24 Jun 2012 23:36
VLC version: 3.0.0-git

Re: Problem using LibVLC

Postby edwardw » 11 Jan 2014 04:42

Check the gdb backtrace.

XilasZ
Developer
Developer
Posts: 189
Joined: 16 Jun 2009 20:35

Re: Problem using LibVLC

Postby XilasZ » 13 Jan 2014 11:52

second parameter of attachSurface must be the java instance which implements setSurfaceSize.
is "NativeUtility.getMainActivity()" the same instance as "this" ? if not, try with "this" instead.

Fradow
Blank Cone
Blank Cone
Posts: 22
Joined: 10 Jan 2014 17:44

Re: Problem using LibVLC

Postby Fradow » 13 Jan 2014 21:56

Thanks for your answers.

Yes it's the same, I checked that it properly implement setSurfaceSize, but it isn't called before the crash (I checked using breakpoints).

I used ndk-gdb to get the stacktrace, but it's weird, here is the full result using the command describe on the wiki (anonymized) :

Code: Select all

~/PROJECT_PATH$ $ANDROID_NDK/ndk-gdb --verbose --force --start Android NDK installation path: /NDK_PATH/android-ndk-r9 Using default adb command: /ADT_PATH/adt-bundle-mac/sdk/platform-tools/adb ADB version found: Android Debug Bridge version 1.0.31 Using ADB flags: Using JDB command: /usr/bin/jdb Using auto-detected project path: . Found package name: com.mycompany.myactivity ABIs targetted by application: armeabi armeabi-v7a x86 Device API Level: 19 Device CPU ABIs: armeabi-v7a armeabi Compatible device ABI: armeabi-v7a Using gdb setup init: /PROJECT_PATH/libs/armeabi-v7a/gdb.setup Using toolchain prefix: /NDK_PATH/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/arm-linux-androideabi- Using app out directory: /PROJECT_PATH/obj/local/armeabi-v7a Found debuggable flag: true Found device gdbserver: /data/data/com.mycompany.myactivity/lib/gdbserver Found data directory: '/data/data/com.mycompany.myactivity' Found first launchable activity: .MyActivity Launching activity: com.mycompany.myactivity/.MyActivity ## COMMAND: adb_cmd shell am start -D -n com.mycompany.myactivity/.MyActivity Starting: Intent { cmp=com.mycompany.myactivity/.MyActivity } ## COMMAND: adb_cmd shell sleep 2 Found running PID: 2434 Launched gdbserver succesfully. Setup network redirection ## COMMAND: adb_cmd forward tcp:5039 localfilesystem:/data/data/com.mycompany.myactivity/debug-socket ## COMMAND: adb_cmd shell run-as com.auticiel.logiral lib/gdbserver +debug-socket --attach 2434 ## COMMAND: adb_cmd pull /system/bin/app_process /PROJECT_PATH/obj/local/armeabi-v7a/app_process Attached; pid = 2434 Listening on Unix socket debug-socket 4134 KB/s (9560 bytes in 0.002s) Pulled app_process from device/emulator. ## COMMAND: adb_cmd pull /system/bin/linker /PROJECT_PATH/obj/local/armeabi-v7a/linker 5941 KB/s (63664 bytes in 0.010s) Pulled linker from device/emulator. ## COMMAND: adb_cmd pull /system/lib/libc.so /PROJECT_PATH/obj/local/armeabi-v7a/libc.so 6199 KB/s (310652 bytes in 0.048s) Pulled libc.so from device/emulator. Setup JDB connection ## COMMAND: adb_cmd forward tcp:65534 jdwp:2434 java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:168) at com.sun.tools.jdi.SocketTransportService.handshake(SocketTransportService.java:112) at com.sun.tools.jdi.SocketTransportService.attach(SocketTransportService.java:214) at com.sun.tools.jdi.GenericAttachingConnector.attach(GenericAttachingConnector.java:98) at com.sun.tools.jdi.SocketAttachingConnector.attach(SocketAttachingConnector.java:72) at com.sun.tools.example.debug.tty.VMConnection.attachTarget(VMConnection.java:358) at com.sun.tools.example.debug.tty.VMConnection.open(VMConnection.java:168) at com.sun.tools.example.debug.tty.Env.init(Env.java:64) at com.sun.tools.example.debug.tty.TTY.main(TTY.java:1010) Fatal error: Unable to attach to target VM. GNU gdb (GDB) 7.3.1-gg2 Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "--host=x86_64-apple-darwin --target=arm-linux-android". For bug reporting instructions, please see: <http://source.android.com/source/report-bugs.html>. Warning: /PROJECT_PATH/../../extensions/CocoStudio/Armature: No such file or directory. Remote debugging from host 0.0.0.0 warning: Breakpoint address adjusted from 0x400caa9d to 0x400caa9c. 0x400c7904 in _start () from /PROJECT_PATH/obj/local/armeabi-v7a/linker (gdb) bt full #0 0x400c7904 in _start () from /PROJECT_PATH/obj/local/armeabi-v7a/linker No symbol table info available. #1 0x400b4670 in ?? () No symbol table info available. #2 0x400b4670 in ?? () No symbol table info available. Backtrace stopped: previous frame identical to this frame (corrupt stack?) (gdb)
That's when I runned it with Eclipse still opened (is it possible to have conflicts with Eclipse debugger ?)

After re-running it with Eclipse closed, I get (skipped until Setup JDB Connection as it is the same) :

Code: Select all

Setup JDB connection ## COMMAND: adb_cmd forward tcp:65534 jdwp:3423 Set uncaught java.lang.Throwable Set deferred uncaught java.lang.Throwable Initializing jdb ... > Input stream closed. GNU gdb (GDB) 7.3.1-gg2 Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "--host=x86_64-apple-darwin --target=arm-linux-android". For bug reporting instructions, please see: <http://source.android.com/source/report-bugs.html>. Warning: /PROJECT_PATH/../../extensions/CocoStudio/Armature: No such file or directory. Remote debugging from host 0.0.0.0 warning: Could not load shared library symbols for 94 libraries, e.g. libstdc++.so. Use the "info sharedlibrary" command to see the complete listing. Do you need "set solib-search-path" or "set sysroot"? warning: Breakpoint address adjusted from 0x40083bf9 to 0x40083bf8. 0x400c7908 in __futex_syscall3 () from /PROJECT_PATH/obj/local/armeabi-v7a/libc.so (gdb) continue Continuing. warning: Could not load shared library symbols for libsoundpool.so. Do you need "set solib-search-path" or "set sysroot"? warning: Could not load shared library symbols for eglsubAndroid.so. Do you need "set solib-search-path" or "set sysroot"? [New Thread 3490] Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 3490] 0x7439d178 in ?? () (gdb) bt full #0 0x7439d178 in ?? () No symbol table info available. #1 0x75e36068 in merge16_armv6 () from /PROJECT_PATH/obj/local/armeabi-v7a/libvlcjni.so No symbol table info available. #2 0x75e36068 in merge16_armv6 () from /PROJECT_PATH/obj/local/armeabi-v7a/libvlcjni.so No symbol table info available. #3 0x00000000 in ?? () No symbol table info available. (gdb) continue Continuing. warning: Could not load shared library symbols for libsc-a3xx.so. Do you need "set solib-search-path" or "set sysroot"? Program received signal SIGSEGV, Segmentation fault. 0x7439d178 in ?? () (gdb)
I can't figure anything about those stacktraces, do someone more experienced have an idea what they could mean ?

Some additional informations I should probably have included before : I am trying to run LibVLC alongside a Cocos2dx SurfaceView (which works fine when using a VideoView instead of LibVLC).
Since I don't want to recompile LibVLC with my project, I copied the library libvlcjni.so from VLC Beta : could that be a problem too ?
The target device is a Nexus 7 2013.

edwardw
Big Cone-huna
Big Cone-huna
Posts: 2346
Joined: 24 Jun 2012 23:36
VLC version: 3.0.0-git

Re: Problem using LibVLC

Postby edwardw » 13 Jan 2014 21:59

Why is it in merge16_armv6?

Shouldn't it be in merge16_arm_neon?

Fradow
Blank Cone
Blank Cone
Posts: 22
Joined: 10 Jan 2014 17:44

Re: Problem using LibVLC

Postby Fradow » 13 Jan 2014 22:03

What did I do that could have caused that ?

I have no clue what merge16 is and how it got there.

edwardw
Big Cone-huna
Big Cone-huna
Posts: 2346
Joined: 24 Jun 2012 23:36
VLC version: 3.0.0-git

Re: Problem using LibVLC

Postby edwardw » 13 Jan 2014 22:04

What happens if you follow http://wiki.videolan.org/AndroidCompile and use your own build of vlc-sdk?

Fradow
Blank Cone
Blank Cone
Posts: 22
Joined: 10 Jan 2014 17:44

Re: Problem using LibVLC

Postby Fradow » 13 Jan 2014 22:10

It works fine and I can read the same video without any issue.

For my own project, instead of recompiling LibVLC from source, I copied the one from VLC project and included it to be copied in my libs after building cocos2dx and the rest of my C++ code. I checked the apk : it does include the library. Could there be a problem with that method ?

edwardw
Big Cone-huna
Big Cone-huna
Posts: 2346
Joined: 24 Jun 2012 23:36
VLC version: 3.0.0-git

Re: Problem using LibVLC

Postby edwardw » 13 Jan 2014 22:11

Then it could be possible that there is a mismatch between the binary API and Java API.

Fradow
Blank Cone
Blank Cone
Posts: 22
Joined: 10 Jan 2014 17:44

Re: Problem using LibVLC

Postby Fradow » 13 Jan 2014 22:14

Thanks a lot for the help.

I'll take the time to properly setup my build script to compile everything from source and report back.

Edit : I looked over the mismatch between the 2 projects. The main culprits seems to be :
- not the same C++ version (my project uses C++11)
- not the same NDK_TOOLCHAIN_VERSION (LibVLC is on 4.6, my project on 4.8)

Fradow
Blank Cone
Blank Cone
Posts: 22
Joined: 10 Jan 2014 17:44

Re: Problem using LibVLC

Postby Fradow » 21 Jan 2014 18:57

Status update

After much time spent, I gave up trying to put LibVLC on my project, and decided to do it the other way around : put my code in the VLC structure and modify the scripts to take it into account.

It's hacky, but unless the VLC devs decide to create an easy way to use only LibVLC in a separate project (which is probably too much to ask), it's the only sane way to do it, since the VLC make scripts are very complicated.

I runned into several issues, mainly because of different flags between my code and LibVLC code, but got it to work in the end.

Please note the above code is probably not correct either, I had to modify it.

edwardw
Big Cone-huna
Big Cone-huna
Posts: 2346
Joined: 24 Jun 2012 23:36
VLC version: 3.0.0-git

Re: Problem using LibVLC

Postby edwardw » 21 Jan 2014 22:09

We do have an easy external LibVLC sdk, you just have to compile and build it, then use vlc-sdk.7z.

Maybe you suggest it would be easier to provide a prebuilt vlc-sdk.7z, if that is what you mean?

Fradow
Blank Cone
Blank Cone
Posts: 22
Joined: 10 Jan 2014 17:44

Re: Problem using LibVLC

Postby Fradow » 21 Jan 2014 22:33

I think I didn't search enough before, indeed there is.

There is no instructions on the wiki on how to use it, and it is buried in a lot of links here https://wiki.videolan.org/LibVLC/

Anyway, I just cloned it to have a look : that won't solve my problem, which was to use LibVLC along another C++ module. My problem was to merge both shell script into a single one. Since I have a very limited knowledge of how the compilation works, I runned into a lot of problems doing that, and it's just more practical to add the compilation of my C++ module into LibVLC compilation script than the other way around.

I didn't find a comprehensive explanation of the different phases of the compilation, and I struggle a lot to understand the code in the shell scripts / MakeFile / Android.mk, that would help a lot.

Thanks for all the help and the work Edward, I appreciate it :)

A Prebuilt vlc-sdk.7z would help if it's possible, yes. Compiling the sdk is a bit hard the first time (between installing all the required tools and properly setting the env), and more importantly it takes a lot of time if you need to recompile the C++ code (unless it's possible to compile separately different modules ?).

P.S. : please note, I may seem to critize, but I really appreciate the work you do, and what is currently available is enough for me.

edwardw
Big Cone-huna
Big Cone-huna
Posts: 2346
Joined: 24 Jun 2012 23:36
VLC version: 3.0.0-git

Re: Problem using LibVLC

Postby edwardw » 21 Jan 2014 22:34

You weren't able to get the sample to work?

Fradow
Blank Cone
Blank Cone
Posts: 22
Joined: 10 Jan 2014 17:44

Re: Problem using LibVLC

Postby Fradow » 21 Jan 2014 22:36

I didn't try again since the first time. Now everything is working fine for me. As I said, my main problem was merging LibVLC and cocos2dx compilation, not getting VLC to work (it did on the first try).

edwardw
Big Cone-huna
Big Cone-huna
Posts: 2346
Joined: 24 Jun 2012 23:36
VLC version: 3.0.0-git

Re: Problem using LibVLC

Postby edwardw » 21 Jan 2014 22:37

Yeah, the VLC build process is a bit complex, so it's best to separately build vlc-sdk/ then compile your own project by dropping its contents in.


Return to “VLC for Android and Chrome OS”

Who is online

Users browsing this forum: No registered users and 9 guests