jibri icon indicating copy to clipboard operation
jibri copied to clipboard

Error "Process ffmpeg hasn't written in 2 seconds, publishing periodic update"

Open MikhailSinelnikov opened this issue 9 months ago • 7 comments

Hello.

We use Kinescope a streaming platform, not YouTube, and we created a script for this:

cat ./ffmpeg
#!/bin/bash

COMANDO="/usr/bin/ffmpeg1"

while test $# -gt 0
do
    T="$1"
    echo =__=$T=__=;
     if [[ "${T:32:57}" =~ ^([a-zA-Z0-9]+)-([a-zA-Z0-9]+)-([a-zA-Z0-9]+)-([a-zA-Z0-9]+)-([a-zA-Z0-9]+) ]]; then
        COMANDO="$COMANDO $T"
    elif [[ "${T:32:65}" =~ ^([a-zA-Z0-9]{32}) ]]; then
        COMANDO="$COMANDO rtmp://rtmp-ru.kinescope.io/${T:32}"
    elif [ "${T:0:32}" == "rtmp://a.rtmp.youtube.com/live2/" ]; then
    COMANDO="$COMANDO rtmp://ovsu.mycdn.me/input/${T:32}"

#       PRESET
#    elif [ "$T" == "veryfast" ];then
#    COMANDO="$COMANDO ultrafast"

#       TIMEOUT

    elif [ "$T" == "-y" ];then
    COMANDO="$COMANDO -y"

#       BITRATE

    elif [ "$T" == "2976k" ];then
#    COMANDO="$COMANDO 8000k -b 8000k -minrate 8000k"
    COMANDO="$COMANDO 8000k"

#       MAX BITARTE

    elif [ "$T" == "5952k" ];then
    COMANDO="$COMANDO 16000k"

#       CBR

    elif [ "$T" == "25" ];then
    COMANDO="$COMANDO 18"

#       FPS

#    elif [ "$T" == "30" ];then
#    COMANDO="$COMANDO 60"

#       GOP
#    elif [ "$T" == "60" ];then
#    COMANDO="$COMANDO 120"

#       AUDIO_DIFF

#    elif [ "$T" == "pulse" ];then
#    COMANDO="$COMANDO alsa"
#    elif [ "$T" == "default" ];then
#    COMANDO="$COMANDO plug:bsnoop"

    elif [ "$T" == "1280x720" ]; then
        COMANDO="$COMANDO 1920x1080"
    elif [ "$T" == "1920x1080" ]; then
        COMANDO="$COMANDO 2560x1440"
     else
        COMANDO="$COMANDO $T"
     fi
    shift
done

echo "Llamando a ffmpeg sustituyendo rtmp si hay: =$COMANDO=."

#echo $COMANDO

exec $COMANDO
PROCESO_FFMPEG=$!

echo "Esperando finalización del proceso: ${PROCESO_FFMPEG}."
wait $PROCESO_FFMPEG

This script run default ffmpeg named ffmpeg1.

At the first launch, logs are not written and an error occurs "Process ffmpeg hasn't written in 2 seconds, publishing periodic update".

When I restart the stream, everything works fine, but sometimes the CPU loads 100%.

What could be the reason?

MikhailSinelnikov avatar Mar 28 '25 13:03 MikhailSinelnikov

That usually means the server is not powerful enough to process the data at realtime speed.

saghul avatar Mar 28 '25 14:03 saghul

@saghul repeated stream launches without restarting the recorder no longer cause this error. The error occurs only the first time

MikhailSinelnikov avatar Mar 28 '25 14:03 MikhailSinelnikov

Is the error fatal?

saghul avatar Mar 28 '25 14:03 saghul

@saghul logs are not recorded for the first time and this is bad, we want to understand the reason

MikhailSinelnikov avatar Mar 28 '25 14:03 MikhailSinelnikov

All it means is that ffmpeg didn't make progress in 2 seconds. Startup could be slower so unless you see an actual problem this should be harmless.

If you do see it while the stream is running, it could imply a performance problem.

saghul avatar Mar 28 '25 14:03 saghul

@saghul If logs are not written, then I see the problem that the stream is interrupted. If I start the stream a second and subsequent times, it does not interrupt.

MikhailSinelnikov avatar Mar 29 '25 18:03 MikhailSinelnikov

After starting the container with a replaced ffmpeg, the first run always results in no logs being written to ffmpeg0.txt, and after 3 minutes, it crashes completely.

@saghul

MikhailSinelnikov avatar Apr 03 '25 14:04 MikhailSinelnikov