datarhei / restreamer

The Restreamer is a complete streaming server solution for self-hosting. It has a visually appealing user interface and no ongoing license costs. Upload your live stream to YouTube, Twitch, Facebook, Vimeo, or other streaming solutions like Wowza. Receive video data from OBS and publish it with the RTMP and SRT server.
https://docs.datarhei.com/restreamer/
Apache License 2.0
3.77k stars 436 forks source link

UI Won't Recognize Raspicam v3 #625

Open CitrusFlavorrr opened 11 months ago

CitrusFlavorrr commented 11 months ago

Subject of the issue I'm very new to working with video-related stuff, so this might be totally obvious. I have a raspberry pi 3 B with 1GB of RAM and a raspicam module v3 with wide angle lens (product code 5658 on adafruit). I've successfully gotten the restreamer container to run and am able to open the UI in a browser on a local computer. However, Raspberry Pi camera doesn't come up as an option in the wizard (picture included). In the config file, I changed camera_auto_detect to start_x and gpu_mem to 256 as recommended. One additional thing I've noticed is that libcamera-hello recognizes the camera when the config file says camera_auto_detect, but now when it is start_x. How can I get the UI to recognize the camera? If there's any other information you need from me just let me know!

Steps to reproduce Start restreamer container using

docker run --detach --name core --privileged --volume /opt/core/config:/core/config --volume /opt/core/data:/core/data --publish 8080:8080 --publish 8181:8181 --publish 1935:1935 --publish 1936:1936 --publish 6000:6000/udp datarhei/restreamer:rpi-latest

Use nano to change camera_auto_detect to start_x and add gpu_mem=256. Relevant section of config file below:

Screenshot 2023-10-01 at 3 19 37 PM

Expected behavior I should see Raspberry Pi Camera as an option in the UI wizard setup on restreamer.

Actual behavior I only see the four other options for video input, but not raspberry pi camera

Screenshot 2023-10-01 at 2 30 44 PM
MattGeale commented 10 months ago

Following as I'm also having the same issue...

ioppermann commented 10 months ago

You should also change the line saying dtoverlay=vc4-kms-v3d to dtoverlay=vc4-fkms-v3d. I updated this in the documation accordingly (https://docs.datarhei.com/restreamer/knowledge-base/user-guides/how-do-i-stream-a-raspicam).

This assumes that you use Raspbian "bullseye".

Please share the output of the command v4l2-ctl --list-devices. The camera might not get detected properly. If the Pi camera is not listed explicitely, you will most likely find it in the "Hardware devices" as mmal service 16.1.

MattGeale commented 10 months ago

Tagging in on this thread since I'm having the same issue... hopefully we can get sorted :)

Followed the updated instructions on the doco... current screenshot of /boot/config.txt

image

Output of v4l2-ctl --list-devices

image

Before making the updated changes to /boot/config, I was able to do libcamera-hello --list-cameras, but now after updating the config file to be what is instructed, it now says no cameras are available.

image

Per your last comment, I've tried selected mmal service 16.1 in restreamer and just get this

image

Let me know your thoughts because I'd be really keen to get it up and running :) Thanks

ioppermann commented 10 months ago

@MattGeale In "legacy mode" (by setting start_x=1 in config.txt), the camera is not anymore accessible by libcamera.

When selecting "mmal service 16.1" during video setup, it might be that the default pixel format (nv12) is not supported by the camera . I suggest that you change into "Advanced setup" where you have more control over the some parameter. image

There you select the "Hardware device" button and then the "mmal service 16.1" device. Change the format to "yuv420p". The other options can stay as they are. Then press "Probe" and it should detect a stream. image

From there you continue with the encoding settings and the audio settings.

I tested this with the Raspicam v2. It should be similar with the Raspicam v3.

MattGeale commented 10 months ago

Hey @ioppermann tried going via the advanced route... image

When checking the probe details...

ffmpeg version 5.1.3-datarhei Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 11.2.1 (Alpine 11.2.1_git20220219) 20220219
  configuration: --extra-version=datarhei --prefix=/usr --extra-libs='-lpthread -lxml2 -lm -lz -lsupc++ -lstdc++ -lssl -lcrypto -lz -lc -ldl' --enable-nonfree --enable-gpl --enable-version3 --enable-postproc --enable-static --enable-openssl --enable-libxml2 --enable-libv4l2 --enable-v4l2_m2m --enable-libfreetype --enable-alsa --enable-libsrt --enable-libx264 --enable-libx265 --enable-libvpx --enable-libmp3lame --enable-libopus --enable-libvorbis --disable-ffplay --disable-debug --disable-doc --disable-shared
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
[video4linux2,v4l2 @ 0x7fb16a5690] ioctl(VIDIOC_STREAMON): Invalid argument
/dev/video0: Invalid argument

Haven't made any changes to config.txt

Only change I made was the resolution as I want to stream in at least 1080p

Let me know your thoughts.

ioppermann commented 10 months ago

Did you try a lower resolution? Or is some other application using the camera at the same time?

Can you post the output of v4l2-ctl --list-formats-ext -d /dev/video0?

MattGeale commented 10 months ago

Apologies for the delay @ioppermann

See attached `$ v4l2-ctl --list-formats-ext -d /dev/video0 ioctl: VIDIOC_ENUM_FMT Type: Video Capture

    [0]: 'YUYV' (YUYV 4:2:2)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [1]: 'UYVY' (UYVY 4:2:2)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [2]: 'YVYU' (YVYU 4:2:2)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [3]: 'VYUY' (VYUY 4:2:2)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [4]: 'RGBP' (16-bit RGB 5-6-5)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [5]: 'RGBR' (16-bit RGB 5-6-5 BE)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [6]: 'RGBO' (16-bit A/XRGB 1-5-5-5)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [7]: 'RGBQ' (16-bit A/XRGB 1-5-5-5 BE)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [8]: 'RGB3' (24-bit RGB 8-8-8)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [9]: 'BGR3' (24-bit BGR 8-8-8)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [10]: 'RGB4' (32-bit A/XRGB 8-8-8-8)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [11]: 'BA81' (8-bit Bayer BGBG/GRGR)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [12]: 'GBRG' (8-bit Bayer GBGB/RGRG)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [13]: 'GRBG' (8-bit Bayer GRGR/BGBG)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [14]: 'RGGB' (8-bit Bayer RGRG/GBGB)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [15]: 'pBAA' (10-bit Bayer BGBG/GRGR Packed)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [16]: 'BG10' (10-bit Bayer BGBG/GRGR)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [17]: 'pGAA' (10-bit Bayer GBGB/RGRG Packed)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [18]: 'GB10' (10-bit Bayer GBGB/RGRG)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [19]: 'pgAA' (10-bit Bayer GRGR/BGBG Packed)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [20]: 'BA10' (10-bit Bayer GRGR/BGBG)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [21]: 'pRAA' (10-bit Bayer RGRG/GBGB Packed)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [22]: 'RG10' (10-bit Bayer RGRG/GBGB)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [23]: 'pBCC' (12-bit Bayer BGBG/GRGR Packed)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [24]: 'BG12' (12-bit Bayer BGBG/GRGR)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [25]: 'pGCC' (12-bit Bayer GBGB/RGRG Packed)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [26]: 'GB12' (12-bit Bayer GBGB/RGRG)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [27]: 'pgCC' (12-bit Bayer GRGR/BGBG Packed)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [28]: 'BA12' (12-bit Bayer GRGR/BGBG)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [29]: 'pRCC' (12-bit Bayer RGRG/GBGB Packed)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [30]: 'RG12' (12-bit Bayer RGRG/GBGB)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [31]: 'pBEE' (14-bit Bayer BGBG/GRGR Packed)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [32]: 'BG14' (14-bit Bayer BGBG/GRGR)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [33]: 'pGEE' (14-bit Bayer GBGB/RGRG Packed)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [34]: 'GB14' (14-bit Bayer GBGB/RGRG)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [35]: 'pgEE' (14-bit Bayer GRGR/BGBG Packed)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [36]: 'GR14' (14-bit Bayer GRGR/BGBG)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [37]: 'pREE' (14-bit Bayer RGRG/GBGB Packed)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [38]: 'RG14' (14-bit Bayer RGRG/GBGB)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [39]: 'GREY' (8-bit Greyscale)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [40]: 'Y10P' (10-bit Greyscale (MIPI Packed))
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [41]: 'Y10 ' (10-bit Greyscale)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [42]: 'Y12P' (12-bit Greyscale (MIPI Packed))
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [43]: 'Y12 ' (12-bit Greyscale)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [44]: 'Y14P' (14-bit Greyscale (MIPI Packed))
            Size: Stepwise 16x16 - 16376x16376 with step 1/1
    [45]: 'Y14 ' (14-bit Greyscale)
            Size: Stepwise 16x16 - 16376x16376 with step 1/1

pi@raspberrypi:~ $`

Turns out I'm running the most recent bookworm - I can reinstall if you think that'll make a difference... pi@raspberrypi:~ $ cat /etc/os-release PRETTY_NAME="Debian GNU/Linux 12 (bookworm)" NAME="Debian GNU/Linux" VERSION_ID="12" VERSION="12 (bookworm)" VERSION_CODENAME=bookworm ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"

Let me know your thoughts.

MattGeale commented 10 months ago

Apologies for the delay @ioppermann

Following this up... downgraded back to bullseye and still same issue listed originally with the invalid argument and the camera being unable to probe.

ffmpeg version 5.1.3-datarhei Copyright (c) 2000-2022 the FFmpeg developers built with gcc 11.2.1 (Alpine 11.2.1_git20220219) 20220219 configuration: --extra-version=datarhei --prefix=/usr --extra-libs='-lpthread -lxml2 -lm -lz -lsupc++ -lstdc++ -lssl -lcrypto -lz -lc -ldl' --enable-nonfree --enable-gpl --enable-version3 --enable-postproc --enable-static --enable-openssl --enable-libxml2 --enable-libv4l2 --enable-v4l2_m2m --enable-libfreetype --enable-alsa --enable-libsrt --enable-libx264 --enable-libx265 --enable-libvpx --enable-libmp3lame --enable-libopus --enable-libvorbis --disable-ffplay --disable-debug --disable-doc --disable-shared libavutil 57. 28.100 / 57. 28.100 libavcodec 59. 37.100 / 59. 37.100 libavformat 59. 27.100 / 59. 27.100 libavdevice 59. 7.100 / 59. 7.100 libavfilter 8. 44.100 / 8. 44.100 libswscale 6. 7.100 / 6. 7.100 libswresample 4. 7.100 / 4. 7.100 libpostproc 56. 6.100 / 56. 6.100 [video4linux2,v4l2 @ 0xf74cac40] ioctl(VIDIOC_STREAMON): Invalid argument /dev/video0: Invalid argument

image

Output of os-release pi@raspberrypi:~ $ cat /etc/os-release PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)" NAME="Raspbian GNU/Linux" VERSION_ID="11" VERSION="11 (bullseye)" VERSION_CODENAME=bullseye ID=raspbian ID_LIKE=debian HOME_URL="http://www.raspbian.org/" SUPPORT_URL="http://www.raspbian.org/RaspbianForums" BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs" pi@raspberrypi:~ $

ioppermann commented 10 months ago

@MattGeale The listed formats are the most common ones. Try to enter a custom format, e.g. yuv422p, rgb24, or yuyv422.

MattGeale commented 10 months ago

image

image

image

ffmpeg version 5.1.3-datarhei Copyright (c) 2000-2022 the FFmpeg developers built with gcc 11.2.1 (Alpine 11.2.1_git20220219) 20220219 configuration: --extra-version=datarhei --prefix=/usr --extra-libs='-lpthread -lxml2 -lm -lz -lsupc++ -lstdc++ -lssl -lcrypto -lz -lc -ldl' --enable-nonfree --enable-gpl --enable-version3 --enable-postproc --enable-static --enable-openssl --enable-libxml2 --enable-libv4l2 --enable-v4l2_m2m --enable-libfreetype --enable-alsa --enable-libsrt --enable-libx264 --enable-libx265 --enable-libvpx --enable-libmp3lame --enable-libopus --enable-libvorbis --disable-ffplay --disable-debug --disable-doc --disable-shared libavutil 57. 28.100 / 57. 28.100 libavcodec 59. 37.100 / 59. 37.100 libavformat 59. 27.100 / 59. 27.100 libavdevice 59. 7.100 / 59. 7.100 libavfilter 8. 44.100 / 8. 44.100 libswscale 6. 7.100 / 6. 7.100 libswresample 4. 7.100 / 4. 7.100 libpostproc 56. 6.100 / 56. 6.100 [video4linux2,v4l2 @ 0xf765ac40] ioctl(VIDIOC_STREAMON): Invalid argument /dev/video0: Invalid argument

Still same issues... tried all three of your suggested; failed to probe source still came up :/

ioppermann commented 10 months ago

@MattGeale This is really strange that none of these formats work, even though they are listed in the v4l2-ctl output. Do you have an original raspicam v3?

MattGeale commented 10 months ago

@MattGeale This is really strange that none of these formats work, even though they are listed in the v4l2-ctl output. Do you have an original raspicam v3?

Yeah I have a raspi-cam v3 noir wide.

image

Ping me on discord if you wanna chat live - might be able to figure out root cause and fix quicker... Mgeale or matt#8119

MattGeale commented 10 months ago

Hey @ioppermann any suggestions? Did you want to ping me on discord?

MattGeale commented 9 months ago

Dont worry about this, I ended up just making my own script and bypassing restreamer.

Too many problems trying to make square peg fit into round hole.

ioppermann commented 9 months ago

@MattGeale Sorry to hear that it didn't work out for you. It seems that the NoIR camera module is not properly represented as a v4l device and ffmpeg has trouble accessing it.

MattGeale commented 9 months ago

ffmpeg doesn't have any issues accessing it.

Made up something in ffmpeg as simple as this, works perfectly fine.

libcamera-vid -t 0 -n --inline \ --width $Width --height $Height \ --framerate $Framerate \ --hdr $HDR --bitrate $Bitrate -o - | \ ffmpeg -re -f lavfi -i anullsrc -c:a aac -r 30 \ -i pipe: -g $(($Framerate * 2)) \ -strict experimental -vcodec copy -map 0:a -map 1:v -b:v $Bitrate -preset veryfast \ -f flv -listen 1 rtmp://0.0.0.0:1935/live/app

Bluscream commented 6 months ago

ffmpeg doesn't have any issues accessing it.

Made up something in ffmpeg as simple as this, works perfectly fine.

libcamera-vid -t 0 -n --inline \ --width $Width --height $Height \ --framerate $Framerate \ --hdr $HDR --bitrate $Bitrate -o - | \ ffmpeg -re -f lavfi -i anullsrc -c:a aac -r 30 \ -i pipe: -g $(($Framerate * 2)) \ -strict experimental -vcodec copy -map 0:a -map 1:v -b:v $Bitrate -preset veryfast \ -f flv -listen 1 rtmp://0.0.0.0:1935/live/app

Glad you got it sorted out. Sad that restreamer wasn't able to help in time :(

giorgio1953 commented 5 months ago

Ich habe genau ddas gleiche Problem. Restreamer erkennt die Raspicam Module 3 nicht.