Closed rommon closed 7 years ago
I did not. But that is awesome. Somehow I missed that all the time. Will play with that around!
I would like to help you with that. Would you point me to the files and maybe give some hints?
That would be great!
I did a little bit of research and that is my current state:
At the moment always a command like parec --format=s16le -d wohnzimmer_dlna.monitor
is used to record the audio data. This data is piped through an encoder with specific arguments and the output of this is transported by HTTP. So basiclly it is e.g. parec --format=s16le -d wohnzimmer_dlna.monitor | lame -b 192
.
When I just enter parec --format=s16le -d wohnzimmer_dlna.monitor
in a terminal parec writes the data to stdout and I get many cryptic symbols representing the actual recorded data.
But as soon as i add the --file-format=wav
option it does not print the data to stdout. Instead it creates a file named wav and writes the data into it.
But we need it to write it to stdout. Thats the problem at the moment.
So I also tried it with named pipes but that just worked for the flac format. (parec --format=s16le -d wohnzimmer_dlna.monitor --file-format=flac >(cat)
)
It did not work with named pipes and wav or oga ...
I just pushed a new branch where i made some changes necessary for the file format stuff.
A sample codec looks like the following:
class PaFlacCodec(BaseCodec):
SUPPORTED_MIME_TYPES = ['audio/flac', 'audio/x-flac']
IDENTIFIER = 'pa_flac'
def __init__(self, mime_string=None):
BaseCodec.__init__(self)
self.priority = 9
self.suffix = 'flac'
self.mime_type = mime_string or 'audio/flac'
@property
def encoder(self):
return pulseaudio_dlna.encoders.NullEncoder()
def get_recorder(self, monitor):
return pulseaudio_dlna.recorders.PulseaudioRecorder(monitor, 'flac')
in this branch there isn't the sample code included, right?
I replaced the FlacCodec class with PaFlacCodec (FlacCodec is not in the code anymore). Furthermore I replaced the identifier to pa_flac in the devices.json file.
It directly worked.
09-26 13:55:50 pulseaudio_dlna.streamserver DEBUG Starting processes "parec --format=s16le -d 192168242sonosplay3_dlna.monitor --file-format=flac | cat"
09-26 13:55:50 pulseaudio_dlna.streamserver INFO Processes of /dWRuPXV1aWQ6UklOQ09OXzAwMEU1OEZFM0MyNjAxNDAwX01S/stream.flac initialized ...
There was some stuttering again at the begining, but I "fixed" that with sliding the volume in pavucontrol.
I have to say that it reacts way faster now on changes in the music streaming, maybe 1,5 seconds. At the beginning it felt like less than a second.
Oh that's cool. What is your OS and pulseaudio version? I did not managed to get it working here ... probably because of different pulseaudio versions.
in this branch there isn't the sample code included, right?
Correct.
Did you try out other codecs? wav would be interesting ...
I am currently testing with wav, but you are right that it is more complicated.
It shows the following.
09-26 17:14:05 pulseaudio_dlna.streamserver INFO Got request from SonosZP.fritz.box - GET /dWRuPXV1aWQ6UklOQ09OXzAwMEU1OEZFM0MyNjAxNDAwX01S/stream.wav HTTP/1.1,200,-
09-26 17:14:05 pulseaudio_dlna.streamserver INFO Client 192.168.2.42 registered to stream /dWRuPXV1aWQ6UklOQ09OXzAwMEU1OEZFM0MyNjAxNDAwX01S/stream.wav.
09-26 17:14:05 pulseaudio_dlna.streamserver DEBUG Starting processes "parec --format=s16le -d 192168242sonosplay3_dlna.monitor --file-format=wav | cat"
09-26 17:14:05 pulseaudio_dlna.streamserver INFO Processes of /dWRuPXV1aWQ6UklOQ09OXzAwMEU1OEZFM0MyNjAxNDAwX01S/stream.wav initialized ...
Failed to open audio file.
09-26 17:14:05 pulseaudio_dlna.streamserver DEBUG Starting processes "parec --format=s16le -d 192168242sonosplay3_dlna.monitor --file-format=wav | cat"
09-26 17:14:05 pulseaudio_dlna.streamserver INFO Processes of /dWRuPXV1aWQ6UklOQ09OXzAwMEU1OEZFM0MyNjAxNDAwX01S/stream.wav reinitialized ...
Failed to open audio file.
09-26 17:14:05 pulseaudio_dlna.streamserver DEBUG Starting processes "parec --format=s16le -d 192168242sonosplay3_dlna.monitor --file-format=wav | cat"
09-26 17:14:05 pulseaudio_dlna.streamserver INFO Processes of /dWRuPXV1aWQ6UklOQ09OXzAwMEU1OEZFM0MyNjAxNDAwX01S/stream.wav reinitialized ...
Failed to open audio file.
09-26 17:14:05 pulseaudio_dlna.streamserver ERROR There were more than 3 attempts to reinitialize the record process. Aborting.
09-26 17:14:05 pulseaudio_dlna.streamserver INFO Processes of /dWRuPXV1aWQ6UklOQ09OXzAwMEU1OEZFM0MyNjAxNDAwX01S/stream.wav reinitialized ...
^C09-26 17:15:06 pulseaudio_dlna.pulseaudio INFO Remove "192168242sonosplay3_dlna" sink ...
Application is shutting down.
09-26 17:15:06 pulseaudio_dlna.pulseaudio INFO Remove "192168242sonosplay3_dlna" sink ...
Failure: No such entity
09-26 17:15:06 pulseaudio_dlna.pulseaudio ERROR Could not remove entity 40
09-26 17:15:06 pulseaudio_dlna.pulseaudio ERROR Could not remove entity 40
If it does reinitialize the process there is something wrong with the command line. Normally it would start the process over and over again, but i inserted a security rule to do this max 3 times in a certain time period.
did you tried to use the already integrated encoder? parec already supports lots of codecs out of the box.
I tested it locally and vlc was able to directly play it. The file is increasing fast, after 1,5 minutes it is already about 11 MB. I guess you have the same "problem" with the current approach.
maybe that will remove some delay and distortion caused by the encoder.
I opened the file with vlc in parallel while recording and vlc had no problems playing the file.