1

I was able to figure out all of my libcamera stream settings needed to stream video from my Camera Module 3 and audio from a USB microphone in my RPi Zero W 2 straight to YouTube, which is as follows:

libcamera-vid -t 0 -g 10 --bitrate 4500000 --inline --width 1920 --height 1080 --framerate 30 --rotation 180 --codec libav --libav-format flv --libav-audio --audio-bitrate 192000 --av-sync 200000 -n -o rtmp://a.rtmp.youtube.com/live2/[STREAM-KEY]

My question is: why do all of the other streaming pipelines I've seen online require the use of FFmpeg? Every single tutorial I have ever seen on streaming video to RTMP with a Raspberry Pi involves piping the feed into FFmpeg first, which seems super complicated and unnecessary.

Is there some benefit to doing that? Is it more efficient somehow? Why can't I just use libcamera-vid and output straight to RTMP as indicated above?

Would appreciate some insight into this, thanks!

Edit: Just to clarify, this is already working perfectly with RTMP. I want to understand why this works, and why I don't have to pipe it into FFmpeg like literally everyone else on Earth who is using libcamera to stream.

Edit: Fixed a typo in code, should be rtmp://

7
  • straight to RTMP ... RTMP is Real-Time Messaging Protocol - I would posit that libcamera-vid doesn't know that particular protocol Commented Apr 3, 2023 at 8:48
  • But it CAN stream to RTMP. I already did it. So what's the issue? Commented Apr 3, 2023 at 15:52
  • oh, libcamera-vid can? then I must've misunderstood the question Commented Apr 3, 2023 at 22:25
  • My question is: why does every code example I find on the web that uses libcamera-vid pipe the result into ffmpeg when the libav codec already does this natively? Do people just not understand what libcamera can do? Commented Apr 5, 2023 at 3:55
  • Perhaps they are using libcamera-apps-lite, which does not use libav Commented Apr 5, 2023 at 5:54

3 Answers 3

0

Based on my experience, directly streaming from libcamera-vid uses less resource and is much better. I used to stream using ffmpeg before i realize that installing the full libcamera-apps instead of lite package allows you to stream from libcamera with lower latency. You can still use ffmpeg if you are more familiar with ffmpeg configuration parameters and are not solely using PiCamera. libcamera won't work with USB cameras.

0

Works well. I use Camera Module 3 and no audio in my RPi P4 straight to YouTube, but i got errors like:Mistake YouTube does not receive enough video data to ensure smooth streaming without buffering. 09:57 Mistake Your encoder sends data faster than real time (several seconds of video per second). You need to set a limit of approximately one second of video per second for uploading your live video. 09:57 Suggestion The audio stream's current bitrate of 0 is below the recommended bitrate. We recommend using an audio stream bitrate of 128 Kbps.

0

Was having trouble with OP's command, finally figured it out, there is a missing "r"

tmp://a.rtmp.youtube.com/live2/[STREAM-KEY]

should be

rtmp://a.rtmp.youtube.com/live2/[STREAM-KEY]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.