Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
MikhailSinelnikov opened this issue Mar 28, 2025 · 7 comments

Comments

@MikhailSinelnikov
Copy link

MikhailSinelnikov commented Mar 28, 2025

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?

@saghul
Copy link
Member

saghul commented Mar 28, 2025

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

@MikhailSinelnikov
Copy link
Author

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

@saghul
Copy link
Member

saghul commented Mar 28, 2025

Is the error fatal?

@MikhailSinelnikov
Copy link
Author

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

@saghul
Copy link
Member

saghul commented Mar 28, 2025

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.

@MikhailSinelnikov
Copy link
Author

@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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants