MediaDetails

This forum is about all development around libVLC.
sheriffjt
New Cone
New Cone
Posts: 3
Joined: 27 Mar 2014 16:26

MediaDetails

Postby sheriffjt » 27 Mar 2014 16:51

Hey everyone,
I just began using VLCJ and had a quick question about how to get MediaDetails. My goal is to scan a folder of videos and get the MediaDetails for each file as efficiently as possible. Currently, I can't do that without displaying the video. I've been using a 75ms delay, grabbing the details, then killing the video, but this hardly seems like the ideal solution. According to the api: "The details are available after the video has started playing, regardless of whether nor not a video output has been created." How can I play the video without displaying it? It seems like even when I do the bare minimum to create the MediaPlayer and play the file, I still get visible video. Any suggestions would really be appreciated. I've included an example below:

Code: Select all

NativeLibrary.addSearchPath( RuntimeUtil.getLibVlcLibraryName(), "C:/Program Files/VideoLAN/VLC"); Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class); MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory(); MediaPlayer mediaPlayer = mediaPlayerFactory.newHeadlessMediaPlayer(); mediaPlayer.playMedia("C:\\Users\\Public\\Videos\\Sample Videos\\Wildlife.wmv"); try { Thread.sleep(75); } catch (InterruptedException e) { LOGGER.error(String.format("ERROR: %s\n",e.getMessage())); } MediaMeta mediaMeta = mediaPlayer.getMediaMeta(); MediaDetails mediaDetails = mediaPlayer.getMediaDetails(); LOGGER.debug(String.format("MEDIA_META: %s\n",mediaMeta.toString())); LOGGER.debug(String.format("MEDIA_PLAYER_LEN: %d\n",mediaPlayer.getLength())); LOGGER.debug(String.format("MEDIA_DETAILS: %s\n",mediaDetails.toString())); mediaPlayer.stop();

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: MediaDetails

Postby sherington » 27 Mar 2014 18:13

For this sort of thing, in all honesty i would consider using something other than libvlc/VLCJ. I do this in my own VLCJ applications by using the "MediaInfo" package. You can launch it from Java (e.g. using commons-exec), or use a Java binding.

http://mediaarea.net/en/MediaInfo

If you download the whole package IIRC there is an example of using the Java binding in there (it's called something like MediaInfo_DLL.java).

If you do want to stick with VLCJ, you can try parsing the media first and then getting the info without playing it, but that does not always provide *all* the information you are looking for.

sheriffjt
New Cone
New Cone
Posts: 3
Joined: 27 Mar 2014 16:26

Re: MediaDetails

Postby sheriffjt » 27 Mar 2014 19:11

Thanks a lot, I'll take a look at MediaInfo. I appreciate the response.

sheriffjt
New Cone
New Cone
Posts: 3
Joined: 27 Mar 2014 16:26

Re: MediaDetails

Postby sheriffjt » 27 Mar 2014 20:19

OK, got it done using Xuggler instead. Fairly easy set up and only a couple lines of code. Thanks for the response!


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 44 guests