I am trying to stream live on Youtube using a Raspberry Pi Zero W and a raspicam. I have installed ffmpeg using the instructions in this link. I am trying to start the streaming on Youtube using the following command:
ffmpeg -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f v4l2 -codec:v h264 -framerate 30 -video_size 1920x1080 -i /dev/video0 -codec:v copy -f flv rtmp://a.rtmp.youtube.com/live2/stream_key
However, whenever I am running the program I always get the following error:
[video4linux2,v4l2 @ 0x2496530] ioctl(VIDIOC_STREAMON): Operation not permitted /dev/video0: Operation not permitted
I have tried the following steps to sort this issue-
- Adding to the video group with
usermod -aG video my_username
then logging out and logging in again.
- Adding the following /etc/modules-load.d/modules.conf file:
snd-bcm2835
i2c-dev
bcm2835-v42l2
- gpu_mem=128 is already set in the /boot/config.txt file
Nothing seems to set the issue and I still get the same error. The camera starts initially for a few seconds and then closes and shows the error message. I have attached the screenshot of the error message. Please suggest what else can I try to sort this issue. Thanks a lot for your time in advance.
1 Answer 1
My rep is too low to comment.
Have you tried lowering the video size, say starting at 320x240? I've streamed video from a Zero W before but never at the resolution you're using. That video size could require up to 15MB/s, see RaspiCam documentation.
Even at modest bitrates I've had the camera lock up and/or the Pi crashes and needs power cycling. I suspect from bits and pieces I've read that the wifi chip doesn't handle high loads very well, or at least it didn't. Have a look at this thread Zero W lockups for some suggestions if that's the case.
For 1080p and 30fps you're asking quite a lot from a single core device.
-
1I think your answer is actually close to an answer, this is a generic error that can occurs when a resource that is busy is accessed again, especially since it starts and then crashes, it is unlikely a permission issue. As you describe the framerate and resolution require a significant amount of computational power and IO bandwidth, so either reducing the framerate or resolution, or both will help.crasic– crasic2019年12月19日 03:42:37 +00:00Commented Dec 19, 2019 at 3:42
-
Hi Paul, thanks for the reply. I changed the video size to 426x240 and lowered the fps to 10 and the camera did run continuously for about 10 minutes to about 6084 frames before crashing again. Ideally, I would like to run it for a much longer duration but I think the high video size and the large fps were the issues in the first place.Prashant– Prashant2019年12月19日 13:40:38 +00:00Commented Dec 19, 2019 at 13:40
-
You could try tweaking a few settings in /boot/config.txt. People claim improved stability using over_voltage=2 and force_turbo=1. The first bumps the core voltage to 1.4V (from 1.35V) and the second keeps the CPU frequency at maximum rather than varying with load. It's suspected varying CPU freq causes instability. Have a look at raspberrypi.org/documentation/configuration/config-txt/… for other options.Paul– Paul2019年12月20日 00:14:38 +00:00Commented Dec 20, 2019 at 0:14
Explore related questions
See similar questions with these tags.
sudo
before the rest of that command.