0

basically what I'm doing is grabbing a twitch stream via streamlink and outputting it to a youtube stream via ffmpeg. When looking up how I could do that I (admittedly) just copied the first command on the documentation and tweaked it a bit and ended up with this command:

 streamlink -O twitch.tv/boxbox best | ffmpeg -i pipe:0 -s 1920x1200 -framerate 30 -vcodec libx264 -preset veryfast -s 1280x720 -threads 0 -f flv "rtmp://a.rtmp.youtube.com/live2/-------------"

running this command works, a stream appears on youtube, but it is very laggy. the console tells me that I'm streaming at a consistent 9fps which is not really what I want. Since this is my very first experience with ffmpeg I dont really know what is causing this. It might even be my server since I'm running a pretty cheap debian VPS. Is this expectable or can I tweak this to stream it better?

diatomym
  • 163
  • 1
  • 2
  • 11

1 Answers1

1

ffmpeg streaming very inefficiently

Since this is my very first experience with ffmpeg I dont really know what is causing this.

What makes you think it's inefficient? You're re-encoding video. This takes a ton of CPU.

It might even be my server since I'm running a pretty cheap debian VPS.

Very likely.

In any case you have a couple options. The best thing to do is to not re-encode the video. If Twitch is giving you H.264 and AAC audio, then use -vcodec copy -acodec copy.

Another thing you can do (although not likely on a VPS) is force hardware acceleration. This will result in some mediocre video quality (not that you probably care anyway since you're already re-encoding a previously encoded video) but will run without significant impact on the CPU. FFmpeg has support for a bunch of GPUs. You'll have to pick one compatible with whatever hardware you're using.

What you should do is not relay the stream, but stream multiple streams from the original source. This will help you avoid quality loss by re-encoding.

Community
  • 1
  • 1
Brad
  • 159,648
  • 54
  • 349
  • 530