How can I improve the frame rate of my Raspberry Pi to YouTube stream?

951 views Asked by At

I am using a Raspberry Pi 4 2GB to live stream to YouTube.

The performance is pretty poor at the moment as I am trying to go through terminal and I feel the setting's are not correct. Performance is OK however if I go directly through YouTube studio and use the 'Webcam' option instead of 'Stream'.

These are the settings that I am currently using:

raspivid -o - -t 0 -vf -hf -fps 30 -b 6000000 | ffmpeg -threads 0 -f v4l2 -i /dev/video0 -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -acodec aac -ab 128k -strict experimental -s 640x480 -b 6000000 -aspect 16:9 -vcodec h264_omx -vb 820k -pix_fmt yuv420p -g 60 -r 30 -f

What options can I change in this command to improve the frame rate and give better performance?

1

There are 1 answers

0
jmsn On

You could try using an encoding preset for the video codec.

E.g.: Add the option -preset veryfast

x264 presets are:

  • ultrafast
  • superfast
  • veryfast
  • faster
  • fast
  • medium – default preset slow
  • slower
  • veryslow

Faster presets should reduce the CPU load of the encode but have negative side effects regarding coding efficiency (file size) and quality -- it's a tradeoff.