mysterons
Posts: 2
Joined: Tue Aug 02, 2022 2:03 pm

Streaming to YouTube with FFMPEG hardware encoding

Tue Aug 02, 2022 2:10 pm

I'm trying to setup a live stream to youtube using a video on my pi and streaming to rtmp.

The pi can just about handle it with whatever default codec it uses:

Code: Select all

ffmpeg -re -i $path -b:v 1M  -preset veryfast -c:a copy -strict -2 -flags +global_header -bsf:a aac_adtstoasc  -f flv rtmp://a.rtmp.youtube.com/live2/stream-code
I don't think this is using the hardware encoding though.

I've tried specifying using h264_v4l2m2m (and much higher quality)

Code: Select all

ffmpeg -re -i $path -s 1920x1080 -c:v h264_v4l2m2m -b:v 4.5M -flags +global_header -f flv rtmp://a.rtmp.youtube.com/live2/stream-code
The pi happily streams away and seems to be keeping up very well, but on youtube I just get a black screen and no sound.

Any ideas what I am doing wrong and how I can get this working?

mysterons
Posts: 2
Joined: Tue Aug 02, 2022 2:03 pm

Re: Streaming to YouTube with FFMPEG hardware encoding

Fri Aug 05, 2022 11:43 am

Ok, for anyone else in the future who tries to do this I found that it works on the 64 bit version of Raspberry Pi OS. Just by chance thought that was worth trying. YouTube still complains that you are streaming it a huge resolution, and that the data rate isn't high enough for this resolution, but it accepts the stream and all looks good and has been stable for me for several hours.

Return to “Other projects”