Page 1 of 1

MediaDetails

Posted: 27 Mar 2014 16:51
by sheriffjt
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();

Re: MediaDetails

Posted: 27 Mar 2014 18:13
by sherington
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.

Re: MediaDetails

Posted: 27 Mar 2014 19:11
by sheriffjt
Thanks a lot, I'll take a look at MediaInfo. I appreciate the response.

Re: MediaDetails

Posted: 27 Mar 2014 20:19
by sheriffjt
OK, got it done using Xuggler instead. Fairly easy set up and only a couple lines of code. Thanks for the response!