1

So I have an ffmpeg command set up that is converting audio piped in through stdin. However, this audio that is being input isn't piped in constantly, and can will stop, sometimes for several seconds, before resuming.

How can I make ffmpeg fill in these paused sections with silence in the output? As the output is being streamed to Icecast, I need it running constantly rather than running some form of post processing on a file.

Is this possible? If so, how would I go about this? If anyone has suggestions of different tools I could use to achieve this I would greatly appreciate it still!

EDIT: The command I'm using to stream the audio is ffmpeg -hide_banner -ac 2 -f s32le -i pipe:0 -ar 48000 -ac 2 -compression_level 10 -c:a libmp3lame -f mp3 -content_type audio/mpeg -vn icecast://source:password@example.com/mount.mp3. When I run this command it works perfectly converting the input from stdin and broadcasting this to icecast. However, when there is a pause in the input ffmpeg stops writing when the input starts up again with the following error:

Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, s32le, from 'pipe:0':
  Duration: N/A, bitrate: 2822 kb/s
    Stream #0:0: Audio: pcm_s32le, 44100 Hz, stereo, s32, 2822 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_s32le (native) -> mp3 (libmp3lame))
Output #0, mp3, to 'icecast://source:password@example.com:mount.mp3':
  Metadata:
    TSSE            : Lavf58.20.100
    Stream #0:0: Audio: mp3 (libmp3lame), 48000 Hz, stereo, s32p
    Metadata:
      encoder         : Lavc58.35.100 libmp3lame
av_interleaved_write_frame(): Broken pipe 128.2kbits/s speed=0.583x    
Error writing trailer of icecast://source:password@example.com:mount.mp3: Broken pipe
size=     286kB time=00:00:18.31 bitrate= 128.0kbits/s speed=0.378x    
video:0kB audio:286kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!
Kezz
  • 133

1 Answers1

1

If you're encountering a problem like this, it's most likely that your Icecast source_timeout is set too low. Try setting it to something unreasonably high or set it to -1 and it won't timeout at all.

This will ensure that ffmpeg will never timeout and the connection will remain open, thus eliminating the need for sending silence to mimic data being sent in the first place.

Kezz
  • 133