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.8k stars 438 forks source link

Problem Restreamer mit Raspicam Module 3 #706

Open giorgio1953 opened 6 months ago

giorgio1953 commented 6 months ago

Guten Tag, meine neue Raspicam Module 3 wird nicht erkannt im Restreamer, bzw. ich bekomme kein Videosignal. Restreamer versucht zu verbinden aber es erscheint immer die Meldung Kein Video. Dies meine Auswahl: Hardwaregerät /dev/video0 Kodierung H.264 (libx264), 4096 kbit/s, 25 FPS, Preset: ultrafast, Profile: auto Filter Keine

Ich danke für Eure Hilfe. mfg Kurt report.txt

ioppermann commented 6 months ago

In den neueren Raspian-Versionen wird die Kamera nicht mehr korrekt als Video4Linux-Gerät zur Verfügung gestellt. Somit ist es FFmpeg nicht möglich den Stream direkt von der Kamera abzugreifen.

Wie in #625 von @MattGeale vorgeschlagen, müsste man auf dem Pi mit libcamera-vid den Stream von der Kamera abgreifen, mit FFmpeg entsprechend encoden und auf den RTMP vom Restreamer schicken. Dazu müsste der Docker container vom Restreamer idealerweise mit der Option --net=host gestartet werden.

Den genauen Befehl müsste ich noch testen, könnte aber so aussehen:

libcamera-vid -t 0 -n --inline \
   --width 1920 --height 1080 \
   --framerate 25 --bitrate 4096k -o - | \
   ffmpeg -re -f lavfi -i anullsrc -c:a aac \
   -i pipe: -r 25  g 50 \ 
   -codec:v copy -map 0:a -map 1:v -b:v 4096k -preset veryfast \
   -f flv rtmp://localhost:1935/live/raspicam
giorgio1953 commented 6 months ago

I became this error

Input #1, h264, from 'pipe:': Duration: N/A, bitrate: N/A Stream #1:0: Video: h264 (High), yuv420p(progressive), 1920x1080, 25 fps, 25 tbr, 1200k tbn [NULL @ 0x55c65a87f0] Unable to find a suitable output format for 'g' g: Invalid argument Received signal 13 Received signal 13 terminate called after throwing an instance of 'std::runtime_error' what(): failed to write output bytes bash: -codec:v: Kommando nicht gefunden.

ioppermann commented 5 months ago

This is the corrected command. I tested it on a fresh Raspbery Pi OS 64bit lite (bookworm) installation.

First install ffmpeg on the system:

sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install ffmpeg rpicam-apps -y

Then use rpicam-vid (same as libcamera-vid) to pull the stream from the camera and send to with ffmpeg to the Restreamer RTMP server:

rpicam-vid -v 0 -t 0 -n --inline \
   --width 1920 --height 1080 --intra 50 \
   --codec h264 --framerate 25 --bitrate 4096k -o - | \
   ffmpeg -thread_queue_size 1024 -f h264 -i - \
   -codec:v copy -f flv rtmp://127.0.0.1:1935/live/raspicam

Or alternatively:

rpicam-vid -v 0 -t 0 -n --inline \
   --width 1920 --height 1080 --intra 50 \
   --framerate 25 --bitrate 4096k \
   --codec libav --libav-format flv -o rtmp://127.0.0.1:1935/live/raspicam

This requires that you already have Restreamer running with the RTMP server enabled. Add the token to the RTMP address if you configured one in the Restreamer settings.