Python Forum
create a "sound" server - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: create a "sound" server (/thread-38237.html)



create a "sound" server - korenron - Sep-20-2022

Hello,
I have a mic connected to my pi
and up until now - when I wanted to hear from the mic I have run this command
ffmpeg -ar 44100 -ac 1 -f alsa -i plughw:1,0 -f wav -listen 1 tcp://0.0.0.0:5002
then I have enter this url in vlc
tcp://10.0.0.1:5002
and I manage to hear
2 problems:
1. I had to connect to the pi (ssh) each time and run the command
2. when I shutdown the VLC , the ffmpeg went down and this is the error message I got:

av_interleaved_write_frame(): Broken pipe 682.1kbits/s speed=1.03x
Error writing trailer of tcp://0.0.0.0:5002: Broken pipe
size=   66181kB time=00:13:14.77 bitrate= 682.1kbits/s speed=1.03x
video:0kB audio:66181kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!
is there something I can do in order to make the ffmpeg stay online and "wait" for clients?

Thanks,


RE: create a "sound" server - Gribouillis - Sep-20-2022

You could perhaps start with the ffmpeg tcp procotol documentation. An example is given
Output:
ffmpeg -i input -f format tcp://hostname:port?listen ffplay tcp://hostname:port
It seems that your syntax for 'listen' is not correct and also that you could try listen=2 to allow multiple connections.


RE: create a "sound" server - korenron - Sep-22-2022

Ok
but when I run with "2"
ffmpeg -ar 44100 -ac 1 -f alsa -i plughw:1,0 -f wav -listen 2 tcp://0.0.0.0:5002
I'm unable to connect and hear anything
when I change it back to "1"
I can hear the sound


RE: create a "sound" server - Gribouillis - Sep-22-2022

Is there any difference if you write tcp://0.0.0.0:5002?listen=2 instead of -listen 2 tcp://0.0.0.0:5002?


RE: create a "sound" server - korenron - Sep-28-2022

same thing
ffmpeg -ar 44100 -ac 1 -f alsa -i plughw:1,0 -f wav tcp://0.0.0.0:5002?listen=2
It won't start - got stuck here
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, alsa, from 'plughw:1,0':
  Duration: N/A, start: 1664365143.171021, bitrate: 705 kb/s
    Stream #0:0: Audio: pcm_s16le, 44100 Hz, mono, s16, 705 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_s16le (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help