Page 1 of 1

VOD mkv with all tracks ( audio and subs )

Posted: 05 Nov 2017 22:26
by kccrocher
Bonjour,
Voici un bon moment que je fais pas mal de recherche sur comment utiliser la librairie vlcj ( vlc avec java ).
J'ai réussi a trouver le moyen pour faire de la VOD ( video a la demande )
Mais malheureusement je n'arrive pas récupérer les sous titres sur cette vod =\
voici le code que j'utilise.

Pour envoyer le film en VOD

Code: Select all

public void ess() throws Exception { String media = "Chemin du media .mkv"; MediaPlayerFactory factory = new MediaPlayerFactory(); MediaManager manager = factory.newMediaManager(); manager.addVideoOnDemand("momie",media, true, null); System.out.println("momie: " + manager.show("momie")); Thread.currentThread().join(); // Don't exit }
pour lire les informarions

Code: Select all

public void start(Film film){ try{ film_playing_info = film; mediaPlayerComponent.getMediaPlayer().playMedia(film_playing_info.getPath()); Date d = Calendar.getInstance().getTime(); while(!parsed){ try { Thread.sleep(100); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } Date d2 = Calendar.getInstance().getTime(); Map<TimeUnit,Long> mmappeurTimer = computeDiff(d,d2); System.out.println(mmappeurTimer.get(TimeUnit.MINUTES)); if(mmappeurTimer.get(TimeUnit.MINUTES) > 1){ break; } System.out.println("WAIT"); } if(justforinfomedia){ EmbeddedMediaPlayer mediaPlayer = mediaPlayerComponent.getMediaPlayer(); System.out.println("OK"); mediaPlayer.getSpu(); List<TrackDescription> audioTracks = mediaPlayer.getAudioDescriptions(); List<TrackDescription> spuTracks = mediaPlayer.getSpuDescriptions(); List<Track> elemSub = new ArrayList<Track>(); List<Track> elemAudio = new ArrayList<Track>(); if( spuTracks.size() > 0){ for(int i = 0; i < spuTracks.size(); i++){ if(spuTracks.get(i).id() != -1){ Track t = new Track(); t.setId(spuTracks.get(i).id()); t.setName(spuTracks.get(i).description().toString()); elemSub.add(t); } } } if( audioTracks.size() > 0){ for(int i = 0; i < audioTracks.size(); i++){ if(audioTracks.get(i).id() != -1){ Track t = new Track(); t.setId(audioTracks.get(i).id()); t.setName(audioTracks.get(i).description().toString()); elemAudio.add(t); } } } long video= mediaPlayer.getLength(); long Heures = TimeUnit.MILLISECONDS.toHours(video); long minutes = TimeUnit.MILLISECONDS.toMinutes(video) - (Heures * 60); long secondes = TimeUnit.MILLISECONDS.toSeconds(video) - (Heures * 3600) - (minutes*60) ; film_playing_info.setTime( Heures + ":"+ minutes+ ":"+secondes); film_playing_info.setSubtitles(elemSub); film_playing_info.setAudio(elemAudio); mediaPlayer.stop(); mediaPlayer.release(); dispose(); } }catch(Exception e){ e.printStackTrace(); } }
La variable parsed et mise a jour par cette event

Code: Select all

@Override public void mediaParsedChanged(MediaPlayer mediaPlayer, int newStatus) { // TODO Auto-generated method stub. if(justforinfomedia){ parsed = true; } }
Voila si vous avez des idées je suis preneur =)
Merci d avance

Re: VOD mkv with all tracks ( audio and subs )

Posted: 28 Nov 2017 13:59
by Jean-Baptiste Kempf
Les sous-titres sont dans le mkv?