mediamtx icon indicating copy to clipboard operation
mediamtx copied to clipboard

Add native support for the Raspberry PI camera

Open aler9 opened this issue 2 years ago • 0 comments

Fixes #1011

Fixes #1010

TODO:

  • [ ] test with Raspberry Pi OS legacy
  • [ ] test with Raspberry Pi OS
  • [ ] test with Raspberry Pi OS 64
  • [ ] enable only with a specific Golang flag in order not to break other architectures
  • [ ] support 64 bit, libcamera and other possible variants
  • [ ] add camera parameters in the configuration file
  • [ ] update README

aler9 avatar Jul 28 '22 12:07 aler9

Codecov Report

Merging #1057 (2f45415) into main (f952ff2) will decrease coverage by 0.59%. The diff coverage is 28.12%.

@@            Coverage Diff             @@
##             main    #1057      +/-   ##
==========================================
- Coverage   65.58%   64.98%   -0.60%     
==========================================
  Files          89       90       +1     
  Lines        7537     7606      +69     
==========================================
  Hits         4943     4943              
- Misses       2172     2241      +69     
  Partials      422      422              
Impacted Files Coverage Δ
internal/conf/path.go 16.66% <0.00%> (-2.14%) :arrow_down:
internal/core/rpicamera_source.go 0.00% <0.00%> (ø)
internal/core/source_static.go 73.58% <57.14%> (-11.42%) :arrow_down:
internal/core/api.go 75.32% <100.00%> (+0.65%) :arrow_up:
internal/core/path.go 72.60% <100.00%> (-0.11%) :arrow_down:
internal/core/path_manager.go 92.20% <0.00%> (+0.45%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov-commenter avatar Aug 11 '22 13:08 codecov-commenter

@aler9 any idea when this will be made available on Docker hub?

cedricve avatar Aug 15 '22 17:08 cedricve

@cedricve the Docker version doesn't support the RPI camera natively, but the standard version does. Just take a look at the README in order to try the feature.

aler9 avatar Aug 16 '22 17:08 aler9

ok thank you just wondering what this PR fixes then? Is it just support for libcamera (but outside a docker container)?

Kind regards, Verstraeten Cédric

On 16 Aug 2022, at 19:21, Alessandro Ros @.***> wrote:

 @cedricve the Docker version doesn't support the RPI camera natively, but the standard version does. Just take a look at the README in order to try the feature.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

cedricve avatar Aug 16 '22 17:08 cedricve

This PR allows the server to interact with libcamera natively, skipping all the Gstreamer stack. GStreamer is not needed anymore.

The Docker version may come in the future, but I have to check whether the camera can be accessed from a container.

aler9 avatar Aug 16 '22 17:08 aler9

it does, is you inject the devices or make it previleged.

Kind regards, Verstraeten Cédric

On 16 Aug 2022, at 19:29, Alessandro Ros @.***> wrote:

 This PR allows the serve to interact with libcamera natively, skipping all the Gstreamer stack. GStreamer is not needed anymore.

The Docker version may come in the future, but I have to check whether the camera can be accessed from a container.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

cedricve avatar Aug 16 '22 17:08 cedricve

Looks awesome, good job!

https://github.com/aler9/rtsp-simple-server/pull/1057/files#diff-fc943529e712158406c15ccb0d56f2afcd02a8d98a193c7623885e3d33366abdR4

I was wondering about those parameters, are there plans to support all of the native parameters with 1:1 names? There's around 40 parameters or more for libcamera-vid --help

I was thinking, maybe instead of hardcoding parameters for libcamera-vid, some kind of wrapper approach could be used instead?

Right now it seems like most of true native Raspberry Pi Camera features/parameters are in fact unavailable, to some degree, but I might be completely wrong. :)

IIRC the bitrate is VBR by default for libcamera

olokos avatar Aug 17 '22 23:08 olokos

In terms of accessing host device from within docker container, that is possible! https://stackoverflow.com/questions/24225647/docker-a-way-to-give-access-to-a-host-usb-or-serial-device

olokos avatar Aug 17 '22 23:08 olokos

I opened two enhancement request in order to track the two features requested by @cedricve and @olokos :

#1110 Allow to use the Raspberry Camera with Docker

#1111 Allow to set additional parameters of the Raspberry Pi Camera

Discussion will be moved there.

aler9 avatar Aug 22 '22 07:08 aler9