raspberry pi, ffmpeg, libmp3lame stream to icecast2 fails with: av_interleaved_write_frame(): Connection reset by peer
<p>finally, i want to merge or mix audio channels from two streams into one new audio stream. but at first i want to relay or reencode an existing stream from an icecast2 server - and send it back to the icecast as new mountpoint. this stream comes from mpd on the same raspberry pi 2. and it works fine.</p>

<p>i've got lame and ffmpeg on this way:</p>

<pre><code>cd /usr/src
git clone https://github.com/rbrito/lame
cd lame
sudo ./configure
sudo make
sudo make install
</code></pre>

<p>then ffmpeg</p>

<pre><code>cd /usr/src
sudo rm -R ffmpeg
git clone git://source.ffmpeg.org/ffmpeg.git
cd ffmpeg
sudo ./configure --arch=armel --target-os=linux --enable-gpl --enable-libmp3lame --enable-nonfree
sudo make
sudo make install
</code></pre>

<p>A simple test fails with:</p>

<pre><code>**av_interleaved_write_frame(): Connection reset by peer
Error writing trailer of icecast://admin:hackme@127.0.0.1:8000/listen: Connection reset by peersize=       5kB time=00:00:00.28 bitrate= 144.7kbits/s speed=1.73x**
</code></pre>

<p>(with strange spaces)</p>

<p>The reencoding ffmpeg script:</p>

<pre><code>ffmpeg \
 -i http://127.0.0.1:8000/live \
 -c:a libmp3lame -b:a 128k \
 -legacy_icecast 1 \
 -content_type audio/mpeg \
 -ice_name "hack radio" \
 -f mp3 icecast://admin:hackme@127.0.0.1:8000/listen \
 -y \
 -stats \
 -report
</code></pre>

<p>I tried legacy_icecast 1 or 0.</p>

<p>The ffmpeg report:</p>

<pre><code>ffmpeg started on 2016-04-09 at 00:57:56
Report written to "ffmpeg-20160409-005756.log"
Command line:
ffmpeg -i http://127.0.0.1:8000/live -muxpreload 10 -c:a libmp3lame -b:a 128k -legacy_icecast 1 -content_type audio/mpeg -ice_name "NFS One Radio" -f mp3 icecast://admin:hackme@127.0.0.1:8000/listen -y -stats -report
ffmpeg version N-79262-gae8a13c Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.6 (Debian 4.6.3-14+rpi1)
  configuration: --arch=armel --target-os=linux --enable-gpl --enable-libmp3lame --enable-nonfree
  libavutil      55. 20.100 / 55. 20.100
  libavcodec     57. 34.100 / 57. 34.100
  libavformat    57. 31.100 / 57. 31.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 41.100 /  6. 41.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Splitting the commandline.
Reading option '-i' ... matched as input file with argument 'http://127.0.0.1:8000/live'.
Reading option '-muxpreload' ... matched as option 'muxpreload' (set the initial demux-decode delay) with argument '10'.
Reading option '-c:a' ... matched as option 'c' (codec name) with argument 'libmp3lame'.
Reading option '-b:a' ... matched as option 'b' (video bitrate (please use -b:v)) with argument '128k'.
Reading option '-legacy_icecast' ... matched as AVOption 'legacy_icecast' with argument '1'.
Reading option '-content_type' ... matched as AVOption 'content_type' with argument 'audio/mpeg'.
Reading option '-ice_name' ... matched as AVOption 'ice_name' with argument 'NFS One Radio'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'mp3'.
Reading option 'icecast://admin:hackme@127.0.0.1:8000/listen' ... matched as output file.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-stats' ... matched as option 'stats' (print progress report during encoding) with argument '1'.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option y (overwrite output files) with argument 1.
Applying option stats (print progress report during encoding) with argument 1.
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input file http://127.0.0.1:8000/live.
Successfully parsed a group of options.
Opening an input file: http://127.0.0.1:8000/live.
[http @ 0x343cee0] Setting default whitelist 'http,https,tls,rtp,tcp,udp,crypto,httpproxy'
[http @ 0x343cee0] request: GET /live HTTP/1.1
User-Agent: Lavf/57.31.100
Accept: */*
Range: bytes=0-
Connection: close
Host: 127.0.0.1:8000
Icy-MetaData: 1


[mp3 @ 0x343c7e0] Format mp3 probed with size=262144 and score=50
[mp3 @ 0x343c7e0] Skipping 656 bytes of junk at 0.
[mp3 @ 0x343c7e0] Before avformat_find_stream_info() pos: 656 bytes read:272000 seeks:0
[mp3 @ 0x343c7e0] All info found
[mp3 @ 0x343c7e0] After avformat_find_stream_info() pos: 42640 bytes read:272000 seeks:0 frames:50
Input #0, mp3, from 'http://127.0.0.1:8000/live':
  Metadata:
    icy-br          : 256
    icy-name        : NFS One Radio
    icy-pub         : 0
    StreamTitle     : x
  Duration: N/A, start: 0.000000, bitrate: 256 kb/s
    Stream #0:0, 50, 1/14112000: Audio: mp3, 44100 Hz, stereo, s16p, 256 kb/s
Successfully opened the file.
Parsing a group of options: output file icecast://admin:hackme@127.0.0.1:8000/listen.
Applying option muxpreload (set the initial demux-decode delay) with argument 10.
Applying option c:a (codec name) with argument libmp3lame.
Applying option b:a (video bitrate (please use -b:v)) with argument 128k.
Applying option f (force format) with argument mp3.
Successfully parsed a group of options.
Opening an output file: icecast://admin:hackme@127.0.0.1:8000/listen.
[icecast @ 0x34492c0] No default whitelist set
[http @ 0x344b9e0] Setting default whitelist 'http,https,tls,rtp,tcp,udp,crypto,httpproxy'
[http @ 0x344b9e0] request: SOURCE /listen HTTP/1.1
User-Agent: Lavf/57.31.100
Accept: */*
Connection: close
Host: 127.0.0.1:8000
Content-Type: audio/mpeg
Icy-MetaData: 1
Ice-Name: NFS One Radio
Ice-Public: 0
Authorization: Basic YWRtaW46bWFyc2Jhc2U=
</code></pre>

<p>The Output from ffmpeg:</p>

<pre><code>ffmpeg started on 2016-04-09 at 01:06:46
Report written to "ffmpeg-20160409-010646.log"
ffmpeg version N-79262-gae8a13c Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.6 (Debian 4.6.3-14+rpi1)
  configuration: --arch=armel --target-os=linux --enable-gpl --enable-libmp3lame --enable-nonfree
  libavutil      55. 20.100 / 55. 20.100
  libavcodec     57. 34.100 / 57. 34.100
  libavformat    57. 31.100 / 57. 31.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 41.100 /  6. 41.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
[mp3 @ 0x25ec7e0] Skipping 501 bytes of junk at 0.
Input #0, mp3, from 'http://127.0.0.1:8000/live':
  Metadata:
    icy-br          : 256
    icy-name        : NFS One Radio
    icy-pub         : 0
    StreamTitle     : x
  Duration: N/A, start: 0.000000, bitrate: 256 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 256 kb/s
Output #0, mp3, to 'icecast://admin:hackme@127.0.0.1:8000/listen':
  Metadata:
    icy-br          : 256
    icy-name        : NFS One Radio
    icy-pub         : 0
    StreamTitle     : x
    TSSE            : Lavf57.31.100
    Stream #0:0: Audio: mp3 (libmp3lame), 44100 Hz, stereo, s16p, 128 kb/s
    Metadata:
      encoder         : Lavc57.34.100 libmp3lame
Stream mapping:
  Stream #0:0 -&gt; #0:0 (mp3 (native) -&gt; mp3 (libmp3lame))
Press [q] to stop, [?] for help
av_interleaved_write_frame(): Connection reset by peer
Error writing trailer of icecast://admin:hackme@127.0.0.1:8000/listen: Connection reset by peersize=      16kB time=00:00:00.96 bitrate= 132.9kbits/s speed=3.14x
video:0kB audio:16kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.183730%
</code></pre>

<p>The icecast works fine with mpd. And icecast creates a new mountpoint when feeded.</p>

<p>For some reason the connection to the icecast drops. Ideas?</p>

<p>Thanks</p>