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 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();
}
}