garkimasera / vlc-rs

Rust bindings for libVLC media framework.
MIT License
67 stars 19 forks source link

crash with example code. #9

Open xrd opened 4 years ago

xrd commented 4 years ago

I'm using this code:

$ file test.mp4 
test.mp4: ISO Media, MP4 v2 [ISO 14496-14]
$ cat src/main.rs 
extern crate vlc;
use vlc::{Instance, Media, MediaPlayer};
use std::thread;

fn main() {
    // Create an instance
    let instance = Instance::new().unwrap();
    // Create a media from a file
    let md = Media::new_path(&instance, "test.mp4").unwrap();
    // Create a media player
    let mdp = MediaPlayer::new(&instance).unwrap();
    mdp.set_media(&md);

    // Start playing
    mdp.play().unwrap();

    // Wait for 10 seconds
    thread::sleep(::std::time::Duration::from_secs(10));

I have this in the Cargo.toml

[dependencies]
vlc-rs = "0.3"

[package]
name = "rust-vlc"
version = "0.0.1"
authors = [ "example.com" ]

When I run I get this:

$ cargo build
    Finished dev [unoptimized + debuginfo] target(s) in 0.00s
$ ./target/debug/rust-vlc 
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
$ rustc --version
rustc 1.39.0
xrd commented 4 years ago

Does this matter?

$ ldd target/debug/rust-vlc
    linux-vdso.so.1 (0x00007fffd6f9b000)
    libvlc.so.5 => /usr/lib/x86_64-linux-gnu/libvlc.so.5 (0x00007fdc754dd000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fdc754d7000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fdc754b4000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fdc7549a000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fdc752a9000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fdc7556d000)
    libvlccore.so.9 => /usr/lib/x86_64-linux-gnu/libvlccore.so.9 (0x00007fdc7519a000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fdc75049000)
    libidn.so.11 => /lib/x86_64-linux-gnu/libidn.so.11 (0x00007fdc75014000)
    libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007fdc74fc5000)
    libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0 (0x00007fdc74f1d000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fdc74f12000)
    liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007fdc74ee9000)
    liblz4.so.1 => /usr/lib/x86_64-linux-gnu/liblz4.so.1 (0x00007fdc74ec9000)
    libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007fdc74dab000)
    libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007fdc74d88000)
garkimasera commented 4 years ago

It seems that libvlc function returns null pointer. Please try call errmsg after the failed function call.

alexandre-janniaux commented 4 years ago

Can you enable verbose logs in the libvlc_new call ?

pjmore commented 4 years ago

Pretty sure I just ran into the same issue, I think that it might have something to do with libvlc dynamically loading plugins like in this SO question: libvlc_new always returns NULL On Ubuntu I was able to fix the issue by installing the vlc package.