[FFmpeg-user] Pad real-time input stream when there is no input data available at this moment

Fusl ffmpeg at lists.dedilink.eu
Thu Jan 9 03:28:42 CET 2014

Hey again,

as it seems that no one actually knows or understands what i'm trying to
do here, i made a short gimp-Painting.


Stream 1 is the main input stream which i need but which sometimes just
freezes and needs to be restarted (it's a ffmpeg process in front of it
piping to this ffmpeg process), which happens automatically. But the
time it takes for the process from being frozen until it restarted it
takes a few seconds, which creates a gap on the stdoutput of the ffmpeg
process. So the final status of ffmpeg-uptime and stdoutput data which
has been processed is (when the ffmpeg script in front has been
restarted 3 times with each restart taking 5 seconds) ffmpeg:3 hours /
data:2 hours, 59 minutes, 45 seconds.

Thank you very much!

On 12/07/2013 01:33 PM, Fusl wrote:
> Hey guys,
> i am currently writing a live-streaming in node.js with ffmpeg and stuck
> at some buffering issues.
> - So what do i have?
> The node.js-script, which manages the stdin source for the following
> ffmpeg process (switch between live-stream and playlist-stream on the fly).
> The ffmpeg-process, called encoder, which takes data from stdin and
> writes them out in mp3 format to stdout.
>  -ac 2
>  -acodec pcm_u8
>  -analyzeduration 5000
>  -ar 48000
>  -f u8
>  -re
>  -i pipe:0
>  -ab 128k
>  -ac 2
>  -acodec libmp3lame
>  -ar 44100
>  -f mp3
>  -flags2 local_header
>  -strict -2
>  pipe:1
> - What is wrong with this bit of code?
> As written above, the node.js script manages the stdin source for the
> ffmpeg-process and therefor switches around live-streaming and
> playlist-streaming (there is also an advertisement-streaming and a
> silence-stream if none of these three streams are sending data).
> Sometimes, the live-streaming source just freezes and the node.js-script
> has to wait for a defined timeout to occur. When this timeout occurs,
> the script disconnects the live-streaming source and connect the
> playlist-streaming source on-the-fly. So far so good, but there is still
> one problem: When the script is waiting for the timeout to occur (for
> example 2 seconds), there is a gap between these streaming sources for
> exact 2 seconds, which is also noticable on the output-stream of the
> ffmpeg-process. Result -> The client needs to resync/rebuffer the stream
> for another 2 seconds. This problem has been temporarily bounded with a
> prebuffering of 25 seconds, done in the node.js-part which processes the
> output of the ffmpeg process but only for about 13 timeouts and then the
> client again needs to resync/rebuffer the stream.
> - So what do i need to fix this issue?
> I need some sort of example of a very complex (i think it is very
> complex) ffmpeg-command, which is doing this:
> When ffmpeg starts, start buffering a real-time anullsrc and pause the
> buffer-processing for now.
> When ffmpeg receives a chunk on stdin (over and over again), reset the
> buffer to 0, pause the buffer-processing and reset the timer for the
> timeout to 0.
> When a timeout of a defined time (e.g. 2 seconds) occurs, resume the
> buffer-processing of the anullsink-buffer so, that also prebuffered
> chunks of anullsrc are being processed.
> Is this somehow possible with ffmpeg or are these a bit too much
> requirements for it?
> PS: If someone wants to check out the code: http://github.com/Fusl/nodecast
> Thank you for your attention!
> Best regards
> Kevin Holly - root at hallowe.lt - http://hallowe.lt/
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user

Best regards

Kevin Holly - root at hallowe.lt - http://hallowe.lt/

More information about the ffmpeg-user mailing list