I just stream using rtmp2sink element to rtmp://a.rtmp.youtube.com/live2/{SECRET_KEY}. Maybe I should switch to backup URL in such cases, but I have no idea on how to do this dynamically with GStreamer.
I think, I found it out. The moment this error happens is when the Pi gets overloaded and YouTube decides, that it doesn’t recieve enough frames. Youtube ends the stream and Pi can’t send data anymore