FFMpeg stream audio problem

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

FFMpeg stream audio problem

Csaba
Hi,

I have Debian Buster Stable and I installed the FFMpeg program.
I would like to stream audio from the microphone of the soundcard to
the local IP of this computer LAN card and other computer can connect
through LAN to play the stream. My goal is to stream audio with lowest
latency as possible. I know that Opus is better than mp3, I only want
to find an operating method for me and test it first. I want to find
the best method to stream audio with low latency, and less CPU usage,
best quality is not important. I have plan to buy Raspberry Pi and use
it for streaming with FFMpeg.
I tried these two scripts to stream:
#!/bin/sh
ffmpeg -f alsa -i plughw:1 -acodec libmp3lame -ar 11025 -f rtp
rtp://192.168.1.20:8000

#!/bin/sh
ffmpeg -f alsa -i plughw:1,0 -acodec libmp3lame -ab 96k -ac 1 -re -f
http http://192.168.1.20:8080

The scripts do not produce any error but stops after start immediately.

Do you have any ideas? What is the problem?

ffmpeg -devices output:
Devices:
 D. = Demuxing supported
 .E = Muxing supported
 --
 DE alsa            ALSA audio output
  E caca            caca (color ASCII art) output device
 DE fbdev           Linux framebuffer
 D  iec61883        libiec61883 (new DV1394) A/V input device
 D  jack            JACK Audio Connection Kit
 D  kmsgrab         KMS screen capture
 D  lavfi           Libavfilter virtual input device
 D  libcdio
 D  libdc1394       dc1394 v.2 A/V grab
 D  openal          OpenAL audio capture device
  E opengl          OpenGL output
 DE oss             OSS (Open Sound System) playback
 DE pulse           Pulse audio output
  E sdl,sdl2        SDL2 output device
 DE sndio           sndio audio playback
 DE video4linux2,v4l2 Video4Linux2 output device
 D  x11grab         X11 screen capture, using XCB
  E xv              XV (XVideo) output device

arecord -l output:

**** List of CAPTURE Hardware Devices ****
card 1: Generic [HD-Audio Generic], device 0: ALC892 Analog [ALC892 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Generic [HD-Audio Generic], device 2: ALC892 Alt Analog
[ALC892 Alt Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

log of the first script:

ffmpeg version 4.1.4-1~deb10u1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr --extra-version='1~deb10u1'
--toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu
--incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl
--disable-stripping --enable-avresample --disable-filter=resample
--enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom
--enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca
--enable-libcdio --enable-libcodec2 --enable-libflite
--enable-libfontconfig --enable-libfreetype --enable-libfribidi
--enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame
--enable-libmysofa --enable-libopenjpeg --enable-libopenmpt
--enable-libopus --enable-libpulse --enable-librsvg
--enable-librubberband --enable-libshine --enable-libsnappy
--enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora
--enable-libtwolame --enable-libvidstab --enable-libvorbis
--enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265
--enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi
--enable-lv2 --enable-omx --enable-openal --enable-opengl
--enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883
--enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100

log of the second script:

ffmpeg version 4.1.4-1~deb10u1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr --extra-version='1~deb10u1'
--toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu
--incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl
--disable-stripping --enable-avresample --disable-filter=resample
--enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom
--enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca
--enable-libcdio --enable-libcodec2 --enable-libflite
--enable-libfontconfig --enable-libfreetype --enable-libfribidi
--enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame
--enable-libmysofa --enable-libopenjpeg --enable-libopenmpt
--enable-libopus --enable-libpulse --enable-librsvg
--enable-librubberband --enable-libshine --enable-libsnappy
--enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora
--enable-libtwolame --enable-libvidstab --enable-libvorbis
--enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265
--enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi
--enable-lv2 --enable-omx --enable-openal --enable-opengl
--enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883
--enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100

Best regards: Csaba
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: FFMpeg stream audio problem

Moritz Barsnick
On Sat, Dec 07, 2019 at 07:43:19 +0100, Csaba wrote:
> #!/bin/sh
> ffmpeg -f alsa -i plughw:1 -acodec libmp3lame -ar 11025 -f rtp rtp://192.168.1.20:8000

This is incorrect.

> #!/bin/sh
> ffmpeg -f alsa -i plughw:1,0 -acodec libmp3lame -ab 96k -ac 1 -re -f http http://192.168.1.20:8080

As is this.

It is so incorrect that ffmpeg should trip over the two usage errors
and report them to you in a very obvious fashion.

Do you happen to be suppressing your output?

My ffmpeg says:
$ ffmpeg -f alsa -i plughw:1,0 -acodec libmp3lame -ab 96k -ac 1 -re -f http http://192.168.1.20:8080
[...]
Option re (read input at native frame rate) cannot be applied to output url http://192.168.1.20:8080 -- you are trying to apply an input option to an output file or vice versa. Move this option before the file it belongs to.
Error parsing options for output file http://192.168.1.20:8080.
Error opening output files: Invalid argument

"-re" is an input option, and shall *not* be used for hardware devices and live feeds - only on files to
*simulate* real-time feeds.

If you remove the "-re" option, ffmpeg will complain about "-f http",
as that is not a format, it's a protocol. You need to supplement the
protocol (which ffmpeg can already recognize from the output URI) with
an actual format.

> The scripts do not produce any error but stops after start immediately.
>
> Do you have any ideas? What is the problem?

I assume something is swallowing your error messages. Or perhaps ffmpeg
indeed gets stuck on the input devices. Have you tried replacing them
with input files (where you may and should add "-re" as an input
option)?

Have you tried just reading the input, and not feeding it to the net?:
$ ffmpeg -f alsa -i plughw:1,0 -f null -

If that still gets stuck without any usefull messages, please add
"-loglevel verbose" or even "-loglevel debug".

Cheers,
Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: FFMpeg stream audio problem

Csaba
Dear Moritz,

Thank you for your help. I appreciate it.

You wrote:

> It is so incorrect that ffmpeg should trip over the two usage errors
> and report them to you in a very obvious fashion.

> Do you happen to be suppressing your output?

I got the output with the following redirection commands:
./scriptname > scriptname.log 2>&1 &
I do not know what happened.

You wrote:

> Have you tried just reading the input, and not feeding it to the net?:
> $ ffmpeg -f alsa -i plughw:1,0 -f null -

It is operating.

I corrected the errors, thank you.
I would like to stream the soundcard input to the net:
#!/bin/sh
ffmpeg -f alsa -i plughw:1,0 -acodec libmp3lame -ac 1 -f mp3
http://192.168.1.20:8080
 but i got a following error log:

Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, alsa, from 'plughw:1,0':
  Duration: N/A, start: 1576038182.094342, bitrate: 1536 kb/s
    Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[tcp @ 0x562b13aa0340] Connection to tcp://192.168.1.20:8080 failed:
Connection refused
<a href="http://192.168.1.20:8080:">http://192.168.1.20:8080: Connection refused

192.168.1.20 is the IP address of this machine's eth0 card. I would
like to connect to this IP address from another machine on my LAN.
I want direct streaming, without a server.
I have read the following in streaming guide that no built-in server.
I do not know to stream it with icecast2 or other server, i would like
to significantly reduce latency. Streaming with VLC is operating and
it produce latency. I would like to try to streaming with ffmpeg but
it even does not work.

Thank you for your help again.

Best regards: Csaba
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: FFMpeg stream audio problem

Moritz Barsnick
On Wed, Dec 11, 2019 at 05:47:49 +0100, Csaba wrote:
> Thank you for your help. I appreciate it.

A pleasure.

> [tcp @ 0x562b13aa0340] Connection to tcp://192.168.1.20:8080 failed:
> Connection refused
> <a href="http://192.168.1.20:8080:">http://192.168.1.20:8080: Connection refused
>
> 192.168.1.20 is the IP address of this machine's eth0 card. I would
> like to connect to this IP address from another machine on my LAN.
> I want direct streaming, without a server.

Ah, understood, I thought so (but you didn't say before).

The syntax you are using tries to connect to an external instance on
192.168.1.20:8080, and forward the stream there.

If you want to host the HTTP server yourself (and have the external
entity connect to you), you can put ffmpeg into that mode with the http
output option "-listen 1".

> to significantly reduce latency. Streaming with VLC is operating and
> it produce latency.

Can you give me the command line syntax for vlc/cvlc? Or do you use the
GUI? I have issues understanding VLC's command line syntax. ;-)

Cheers,
Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: FFMpeg stream audio problem

Csaba
Hi Moritz,

Thank you very much for your mail. I am so sorry for my mistakes. You
are very friendly and helpful.

I have better success with VLC than ffmpeg. My simple goal is to make
audio streaming on my Linux machine. I would like to other machines
and mobile phones can connect to the Linux machine (192.168.1.20) and
can play the stream with low latency.

I tried the following:
#!/in/sh
cvlc -vvv alsa://hw:1,0 --sout-keep --sout
'#transcode{acodec=mp3,ab=128,channels=2,samplerate=9600}:standard{access=http,dst=192.168.1.20:8888/stream.mp3,caching=0}'
> vlc_tcp_stream.log 2>&1 &
I tried to set some caching options too but these options did not
decrease latency.
I tried to stream PCM but i made a mistake.
cvlc -vvv alsa://plughw:1,0 --sout
'#transcode{acodec=s16b,samplerate=44100}:standard{access=http,dst=192.168.1.20:8888/stream.pcm}'
> vlc_pcm.log 2>&1 &
I also tried with "araw" with no success.

I also tried rtp streaming with Ffmpeg. In this case where do I put
the "-listen 1" parameter?
#!/bin/sh
arecord -D plughw:1,0 -r 44100 -c 2 -f S16_LE | ffmpeg -i - -acodec
mp2 -ab 320k -ac 1 -f rtp rtp://192.168.1.20:5000 > ffmpeg_rtp.log
2>&1 &
The stream is operating but i unable to connect from other machine.

Best regards: Csaba
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: FFMpeg stream audio problem

Moritz Barsnick
On Wed, Dec 11, 2019 at 16:46:13 +0100, Csaba wrote:
> #!/in/sh
> cvlc -vvv alsa://hw:1,0 --sout-keep --sout
> '#transcode{acodec=mp3,ab=128,channels=2,samplerate=9600}:standard{access=http,dst=192.168.1.20:8888/stream.mp3,caching=0}'
> > vlc_tcp_stream.log 2>&1 &

Thanks for these. I always want to try vlc for certain stuff, but get
scared a bit. ;-)

> I also tried rtp streaming with Ffmpeg. In this case where do I put
> the "-listen 1" parameter?

As far as I understand, the rtp protocol is always a listening server,
no extra option needed.

> #!/bin/sh
> arecord -D plughw:1,0 -r 44100 -c 2 -f S16_LE | ffmpeg -i - -acodec
> mp2 -ab 320k -ac 1 -f rtp rtp://192.168.1.20:5000 > ffmpeg_rtp.log
> 2>&1 &
> The stream is operating but i unable to connect from other machine.

I can't help you with that. Are ports 5000 and 5001 open, and
accessable from the other machine?

Other question: Did the http "-listen" option work for you?

Regards,
Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: FFMpeg stream audio problem

Csaba
Hi Moritz,

Thank you very much, you are very friendly and helpful.

You wrote:

> Thanks for these. I always want to try vlc for certain stuff, but get
> scared a bit. ;-)
I found these command line parameters somewhere on the net. I am a novice. :-(

> As far as I understand, the rtp protocol is always a listening server,
> no extra option needed.

> > #!/bin/sh
> > arecord -D plughw:1,0 -r 44100 -c 2 -f S16_LE | ffmpeg -i - -acodec
> > mp2 -ab 320k -ac 1 -f rtp rtp://
192.168.1.20:5000
>  > ffmpeg_rtp.log
> > 2>&1 &
> > The stream is operating but i unable to connect from other machine.

> I can't help you with that. Are ports 5000 and 5001 open, and
> accessable from the other machine?

It seems that these ports are not open. I have base install of Debian
stable, i have no active firewall. When I install IPtables, everything
is empty and "accept" status. Do i need to install some other packages
to work with RTP protocol?

netstat -tul
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN
udp        0      0 0.0.0.0:52177           0.0.0.0:*
udp        0      0 0.0.0.0:52178           0.0.0.0:*
udp        0      0 0.0.0.0:bootpc          0.0.0.0:*

What is the problem with this situation?

> Other question: Did the http "-listen" option work for you?

Unfortunately, not. Because i am a novice, i always put wrong place
the "-listen" parameter in the commandline and the program complains
about error.
#!/bin/sh
ffmpeg -f alsa -i plughw:1,0 -acodec libmp3lame -ac 1 -f mp3
http://192.168.1.20:8080
Where do i put the -listen 1 parameter to avoid an error?

I am so sorry, i am a beginner.

I wish you nice day, good weekend.

Best regards: Csaba


2019-12-12 11:38 GMT+01:00, Moritz Barsnick <[hidden email]>:

> On Wed, Dec 11, 2019 at 16:46:13 +0100, Csaba wrote:
>> #!/in/sh
>> cvlc -vvv alsa://hw:1,0 --sout-keep --sout
>> '#transcode{acodec=mp3,ab=128,channels=2,samplerate=9600}:standard{access=http,dst=192.168.1.20:8888/stream.mp3,caching=0}'
>> > vlc_tcp_stream.log 2>&1 &
>
> Thanks for these. I always want to try vlc for certain stuff, but get
> scared a bit. ;-)
>
>> I also tried rtp streaming with Ffmpeg. In this case where do I put
>> the "-listen 1" parameter?
>
> As far as I understand, the rtp protocol is always a listening server,
> no extra option needed.
>
>> #!/bin/sh
>> arecord -D plughw:1,0 -r 44100 -c 2 -f S16_LE | ffmpeg -i - -acodec
>> mp2 -ab 320k -ac 1 -f rtp rtp://192.168.1.20:5000 > ffmpeg_rtp.log
>> 2>&1 &
>> The stream is operating but i unable to connect from other machine.
>
> I can't help you with that. Are ports 5000 and 5001 open, and
> accessable from the other machine?
>
> Other question: Did the http "-listen" option work for you?
>
> Regards,
> Moritz
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".