I am using a Pi Zero W with the Pi camera (noir) to stream live to Youtube using ffmpeg. The command line I am using is:
raspivid -o - -t 0 -h 720 -w 1296 -fps 24 -b 6000000 | ./ffmpeg -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -thread_queue_size 512 -i - -vcodec copy -acodec aac -ab 128k -g 50 -preset ultrafast -crf 32 -strict experimental -f flv rtmp://173.194.183.168/live2/<MY_YOUTUBE_KEY>
When this starts running, I initially get a speed of ~1.5x/45 FPS. I assume that this reported speed is the rate at which ffmpeg is able to encode and send the output of raspivid. After this command has been running for a few minutes, the speed will (always) monotonically degrade until the FPS is less than the input (24), and the stream starts to lag. I have tried a number of changes to the command, including smaller video, lower frame-rate, lower quality, and even streaming to a local file instead of YouTube. The behaviour remains in all cases, and it seems as if ffmpeg itself is getting slower the longer it runs.
Does anyone have any idea what might be going on here, and how I can resolve this?