Using vlcj to direct audio to File output
Posted: 12 Nov 2018 23:59
Hi All,
I am trying to stream an rtsp stream that has audio and video and save those streams to file, one audio and one video.
Saving the video file has not ben a problem but when I try to direct the audio to a file I get a stream output error.
The following is a snippet of the code I'm trying to use.
As you can tell I've tried a bunch of different ways to get the audio to be directed to file, but, without any success.
Is there a way to achieve this when I get the information on output devices it only shows output going to speakers.
Any help with this would be greatly appreciated.
We are using the libVLC or vlcj 3.10.1.
Hopefully this is the correct forum for this.
Thanks,
Jeff
String options = ":sout-all=#transcode{vcodec=h264,acodec=mpg3,ab=128,channels=2,samplerate=44100}:file{dst=testAudioFile.mpg}:sout-keep}";
logger.log(Level.INFO, "Audio options = " + options.toString());
logger.log(Level.INFO, "Audio fileOption = " + fileOption.toString());
//mediaPlayer.setStandardMediaOptions(options);
//mediaPlayer.setAudioChannel(0);
//mediaPlayer.playMedia(streamPath, options);
boolean mediaPlayerPlayinMedia = mediaPlayer.playMedia("rtsp://10.118.10.150/audioIn/stream0", options);
logger.log(Level.INFO, "mediaPlayerPlayMedia result = " + mediaPlayerPlayinMedia);
List<TrackDescription> trackDescription = mediaPlayers.get(monitor.getScreenName()).getAudioDescriptions();
logger.log(Level.INFO, "Track description = " + trackDescription.toString());
List<uk.co.caprica.vlcj.player.AudioDevice> audioDeviceList = mediaPlayers.get(monitor.getScreenName()).getAudioOutputDevices();
logger.log(Level.INFO, "AudioDevice devices = " + audioDeviceList.toString());
String audioDeviceIdString = "";
for (uk.co.caprica.vlcj.player.AudioDevice audioDevice : audioDeviceList)
{
logger.log(Level.INFO, "AudioDevice string = " + audioDevice.toString());
// if (!deviceString.isEmpty())
// {
// audioDeviceIdString = deviceString;
// logger.log(Level.INFO, "Breaking out AudioDevice string = " + deviceString);
// break;
// }
}
I am trying to stream an rtsp stream that has audio and video and save those streams to file, one audio and one video.
Saving the video file has not ben a problem but when I try to direct the audio to a file I get a stream output error.
The following is a snippet of the code I'm trying to use.
As you can tell I've tried a bunch of different ways to get the audio to be directed to file, but, without any success.
Is there a way to achieve this when I get the information on output devices it only shows output going to speakers.
Any help with this would be greatly appreciated.
We are using the libVLC or vlcj 3.10.1.
Hopefully this is the correct forum for this.
Thanks,
Jeff
String options = ":sout-all=#transcode{vcodec=h264,acodec=mpg3,ab=128,channels=2,samplerate=44100}:file{dst=testAudioFile.mpg}:sout-keep}";
logger.log(Level.INFO, "Audio options = " + options.toString());
logger.log(Level.INFO, "Audio fileOption = " + fileOption.toString());
//mediaPlayer.setStandardMediaOptions(options);
//mediaPlayer.setAudioChannel(0);
//mediaPlayer.playMedia(streamPath, options);
boolean mediaPlayerPlayinMedia = mediaPlayer.playMedia("rtsp://10.118.10.150/audioIn/stream0", options);
logger.log(Level.INFO, "mediaPlayerPlayMedia result = " + mediaPlayerPlayinMedia);
List<TrackDescription> trackDescription = mediaPlayers.get(monitor.getScreenName()).getAudioDescriptions();
logger.log(Level.INFO, "Track description = " + trackDescription.toString());
List<uk.co.caprica.vlcj.player.AudioDevice> audioDeviceList = mediaPlayers.get(monitor.getScreenName()).getAudioOutputDevices();
logger.log(Level.INFO, "AudioDevice devices = " + audioDeviceList.toString());
String audioDeviceIdString = "";
for (uk.co.caprica.vlcj.player.AudioDevice audioDevice : audioDeviceList)
{
logger.log(Level.INFO, "AudioDevice string = " + audioDevice.toString());
// if (!deviceString.isEmpty())
// {
// audioDeviceIdString = deviceString;
// logger.log(Level.INFO, "Breaking out AudioDevice string = " + deviceString);
// break;
// }
}