Using vlcj to direct audio to File output

This forum is about all development around libVLC.
jeff1965
New Cone
New Cone
Posts: 8
Joined: 12 Nov 2018 23:45

Using vlcj to direct audio to File output

Postby jeff1965 » 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;
// }
}

jeff1965
New Cone
New Cone
Posts: 8
Joined: 12 Nov 2018 23:45

Re: Using vlcj to direct audio to File output

Postby jeff1965 » 13 Nov 2018 00:03

A bit more of the code that didn't get into my paste buffer.

mediaPlayer.setAudioOutputDevice(fileOption, audioDeviceIdString);



logger.log(Level.INFO, "audioOutputSettingSucceeded maybe ????");
mediaPlayer.stop();
mediaPlayer.play();
int trackCount = mediaPlayer.getAudioTrackCount();
logger.log(Level.INFO, "Track Count = " +trackCount);

mfkl
Developer
Developer
Posts: 739
Joined: 13 Jun 2017 10:41

Re: Using vlcj to direct audio to File output

Postby mfkl » 13 Nov 2018 04:00

I get a stream output error.
Please share some logs.
https://mfkl.github.io

jeff1965
New Cone
New Cone
Posts: 8
Joined: 12 Nov 2018 23:45

Re: Using vlcj to direct audio to File output

Postby jeff1965 » 13 Nov 2018 19:46

Here is some output from the log file.

Thanks,
Jeff
INFO: Starting recording...stream: rtsp://10.118.10.150/audioIn/stream0 file at:
:sout=file:C:\gnd\MissionDataRecorder\videos\recording20181112135152\Operator1a
udio.mpg
[000000002d6b4830] mux_ps mux: Open
Nov 12, 2018 1:51:54 PM net.sys.gnd.MissionDataRecorder.OperatorVideoPanel start
Recording
INFO: Start Recording...stream: 10.118.10.150/audioIn/stream0
Nov 12, 2018 1:51:54 PM net.sys.gnd.MissionDataRecorder.OperatorVideoPanel start
Recording
INFO: Start Recording...name: audio
Nov 12, 2018 1:51:54 PM net.sys.gnd.MissionDataRecorder.OperatorVideoPanel playW
ithRecording
INFO: Should have started recording...
Nov 12, 2018 1:51:54 PM net.sys.gnd.MissionDataRecorder.OperatorVideoPanel playW
ithRecording
INFO:

monitor.getScreenName() = audio
Nov 12, 2018 1:51:54 PM net.sys.gnd.MissionDataRecorder.OperatorVideoPanel playW
ithRecording
INFO:


Nov 12, 2018 1:51:54 PM net.sys.gnd.MissionDataRecorder.OperatorVideoPanel playW
ithRecording
INFO: Audio options = :sout=#transcode{vcodec=h264,acodec=mpg3,ab=128,channels=2
,samplerate=44100}:file{dst=testAudioFile.mpg}:sout-keep}
Nov 12, 2018 1:51:54 PM net.sys.gnd.MissionDataRecorder.OperatorVideoPanel playW
ithRecording
INFO: Audio fileOption = :sout=file:C:\gnd\MissionDataRecorder\videos\recording2
0181112135152\Operator1audio.mpg
[000000002ad300f0] core stream output error: Nov 12, 2018 1:51:54 PM net.sys.gnd
.MissionDataRecorder.OperatorVideoPanel playWithRecording
INFO: mediaPlayerPlayMedia result = true
stream chain failed for `transcode{vcodec=h264,acodec=mpg3,ab=128,channels=2,sam
plerate=44100}:file{dst=testAudioFile.mpg}:sout-keep}'
[000000000031dcb0] core input error: Nov 12, 2018 1:51:54 PM net.sys.gnd.Mission
DataRecorder.OperatorVideoPanel playWithRecording
INFO: Track description = [TrackDescription[id=-1,description=Disable], TrackDes
cription[id=0,description=Track 1]]
cannot start stream output instance, aborting
Nov 12, 2018 1:51:54 PM net.sys.gnd.MissionDataRecorder.OperatorVideoPanel playW
ithRecording
INFO: AudioDevice devices = [AudioDevice[deviceId=,longName=Default], AudioDevic
e[deviceId={16558CB5-3FB6-48C2-9EF9-362E2D5E51E6},longName=Speakers (High Defini
tion Audio Device)]]
Nov 12, 2018 1:51:54 PM net.sys.gnd.MissionDataRecorder.OperatorVideoPanel playW
ithRecording
INFO: audioOutputSettingSucceeded maybe ????
[000000002ad301f0] core stream output error: stream chain failed for `transcode{
vcodec=h264,acodec=mpg3,ab=128,channels=2,samplerate=44100}:file{dst=testAudioFi
le.mpg}:sout-keep}'Nov 12, 2018 1:51:54 PM net.sys.gnd.MissionDataRecorder.Opera
torVideoPanel playWithRecording
INFO: Track Count = 0

[000000000031da70] core input error: cannot start stream output instance, aborti
ng

jeff1965
New Cone
New Cone
Posts: 8
Joined: 12 Nov 2018 23:45

Re: Using vlcj to direct audio to File output

Postby jeff1965 » 13 Nov 2018 19:47

Also I do get the audio over the speakers, but, would like to save the audio to file.

mfkl
Developer
Developer
Posts: 739
Joined: 13 Jun 2017 10:41

Re: Using vlcj to direct audio to File output

Postby mfkl » 14 Nov 2018 04:31

Start VLC, enable logging, get the result you want using the GUI (if you can) and look at the generated transcode string in the logs.
https://mfkl.github.io

jeff1965
New Cone
New Cone
Posts: 8
Joined: 12 Nov 2018 23:45

Re: Using vlcj to direct audio to File output

Postby jeff1965 » 14 Nov 2018 22:44

OK I'll try that. There was a transcode ldefenition in the vlc gui that I have been trying.
Thanks, I'll let you know how it goes. Where do the logs get saved/generated?

MisterBlack
New Cone
New Cone
Posts: 2
Joined: 14 Nov 2018 00:10

Re: Using vlcj to direct audio to File output

Postby MisterBlack » 14 Nov 2018 22:49

OK I'll try that. There was a transcode ldefenition in the vlc gui that I have been trying.
Thanks, I'll let you know how it goes. Where do the logs get saved/generated?
Assuming you're using VLC Player you need to turn them on by going to Tools > Preferences and then under "Show Settings" click all. Under Advanced you'll see Logger, make sure "Log to file" is checked and set the log filename. I set verbosity to debug and keep the format to Text.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 27 guests