soyersoyer / fmp4streamer

Fmp4streamer streams your V4L2 camera directly to any browser and media player as MP4 (H264).
Apache License 2.0
80 stars 7 forks source link

Logitech C920 no H264 on Pi Zero W #7

Closed 350d closed 2 years ago

350d commented 2 years ago

I have C920 here and 1920x1080@30fps doesn't work. Raspberry Pi Zero W + OS Buster Lite version. Only I can get is 5 fps with capture_format = YUYV

Device: /dev/video0
Name: HD Pro Webcam C920
Driver: uvcvideo

Controls
brightness = 128    ( default: 128 min: 0 max: 255)
contrast = 128  ( default: 128 min: 0 max: 255)
saturation = 128    ( default: 128 min: 0 max: 255)
white_balance_temperature_auto = 1  ( default: 1 min: 0 max: 1)
gain = 169  ( default: 0 min: 0 max: 255)
power_line_frequency = 60 Hz    ( default: 60 Hz values: 'Disabled' '50 Hz' '60 Hz' )
white_balance_temperature = 3066    ( default: 4000 min: 2000 max: 6500)
sharpness = 128 ( default: 128 min: 0 max: 255)
backlight_compensation = 0  ( default: 0 min: 0 max: 1)
exposure_auto = Aperture Priority Mode  ( default: Aperture Priority Mode values: 'Manual Mode' 'Aperture Priority Mode' )
exposure_absolute = 333 ( default: 250 min: 3 max: 2047)
exposure_auto_priority = 1  ( default: 0 min: 0 max: 1)
pan_absolute = 0    ( default: 0 min: -36000 max: 36000 step: 3600)
tilt_absolute = 0   ( default: 0 min: -36000 max: 36000 step: 3600)
focus_absolute = 0  ( default: 0 min: 0 max: 250 step: 5)
focus_auto = 1  ( default: 1 min: 0 max: 1)
zoom_absolute = 100 ( default: 100 min: 100 max: 500)
uvcx_h264_stream_mux = None ( default: None values: 'None' 'H264' )
uvcx_h264_width = 1920  ( default: 1920 min: 160 max: 1920)
uvcx_h264_height = 1080 ( default: 1080 min: 120 max: 1080)
uvcx_h264_frame_interval = 333333   ( default: 333333 min: 333333 max: 2000000)
uvcx_h264_bitrate = 3000000 ( default: 3000000 min: 64000 max: 12000000)
uvcx_h264_rate_control_mode = CBR   ( default: CBR values: 'CBR' 'VBR' 'Const QP' )
uvcx_h264_profile = Constrained ( default: Constrained values: 'Constrained' 'Baseline' 'Main' 'High' )
uvcx_h264_i_frame_period = 10000    ( default: 10000 min: 0 max: 50000)
uvcx_h264_slice_mode = SlicesPerFrame   ( default: SlicesPerFrame values: 'Off' 'BitsPerSlice' 'MBsPerSlice' 'SlicesPerFrame' )
uvcx_h264_slice_units = 4   ( default: 4 min: 0 max: 68)
uvcx_h264_entropy = CAVLC   ( default: CAVLC values: 'CAVLC' 'CABAC' )
uvcx_h264_usage = Realtime  ( default: Realtime values: 'Realtime' 'Broadcast' 'Storage' )
uvcx_h264_leaky_bucket_size = 1000  ( default: 1000 min: 500 max: 4000)

Device: /dev/video11
Name: bcm2835-codec-encode
Driver: bcm2835-codec

Controls

Codec Controls

video_bitrate_mode = Variable Bitrate   ( default: Variable Bitrate values: 'Variable Bitrate' 'Constant Bitrate' )
video_bitrate = 10000000    ( default: 10000000 min: 25000 max: 25000000 step: 25000)
sequence_header_mode = Joined With 1st Frame    ( default: Joined With 1st Frame values: 'Separate Buffer' 'Joined With 1st Frame' )
repeat_sequence_header = 0  ( default: 0 min: 0 max: 1)
Force Key Frame = 
h264_i_frame_period = 1 ( default: 60 min: 0 max: 2147483647)
h264_level = 4.2    ( default: 4 values: '1' '1b' '1.1' '1.2' '1.3' '2' '2.1' '2.2' '3' '3.1' '3.2' '4' '4.1' '4.2' )
h264_profile = High ( default: High values: 'Baseline' 'Constrained Baseline' 'Main' 'High' )

To set one, put ctrl_name = Value into fmp4streamer.conf under the device
soyersoyer commented 2 years ago

My C920 only supports 1920x1080@5fps in YUYV mode. Check out with v4l2-ctl --list-formats-ext. Fortunately you can use the C920's H264 encoder for higher fps with the capture_format = H264. Or you can use Pi4 with an USB3 webcam in YUYV mode and use the pi's encoder.

350d commented 2 years ago

1920x1080 listed under H264 and MJPG but both not available for capture_format for some reason.

Errors for other than YUYV:

ERROR:root:/dev/video11: H264 input format not available OR ERROR:root:/dev/video11: MJPG input format not available

ioctl: VIDIOC_ENUM_FMT
    Type: Video Capture

    [0]: 'YUYV' (YUYV 4:2:2)
        ...
        Size: Discrete 1920x1080
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 2304x1296
            Interval: Discrete 0.500s (2.000 fps)
        Size: Discrete 2304x1536
            Interval: Discrete 0.500s (2.000 fps)
    [1]: 'H264' (H.264, compressed)
        ...
        Size: Discrete 1920x1080
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
    [2]: 'MJPG' (Motion-JPEG, compressed)
        ...
        Size: Discrete 1920x1080
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)

My config:

[server]
listen = 
port = 8000

[/dev/video0]
width = 1920
height = 1080
fps = 30
capture_format = MJPG
encoder = /dev/video11

focus_auto = 0
power_line_frequency = 50 Hz

[/dev/video11]

h264_profile = High
h264_level = 4.2
h264_i_frame_period = 15

uvcx_h264_i_frame_period = 1000
uvcx_h264_profile = High
soyersoyer commented 2 years ago

try with this config:

[server]
listen = 
port = 8000

[/dev/video0]
width = 1920
height = 1080
fps = 30
capture_format = H264

focus_auto = 0
power_line_frequency = 50 Hz
uvcx_h264_i_frame_period = 1000
uvcx_h264_profile = High

The /dev/video11 is the H264 encoder on a Pi. You can use that if your camera doesn't support H264.

350d commented 2 years ago

It works!

soyersoyer commented 2 years ago

Cool! :)