v4l2 grabber : 'MJPG' pixel format support

  • Well, it is possible, just with a bit of extra work. I am not sure how easy would it be with open/libreelec since you need to compile extra kernel module, I've made it with arch linux.


    The USB grabber I have uses uvcvide kernel module, it is available in default arch install.


    Next step - get v4l2loopback from https://github.com/umlaeute/v4l2loopback , compile and install (you'll need to install make and gcc packages for this).
    # modprobe v4l2loopback
    You'll get /dev/video1 device created, this is a virtual video device.


    Now we can use gstreamer to convert mjpeg stream from /dev/video0 into hyperion compatible stream on /dev/video1.
    I am using this command (needs gstreamer, gst-plugins-good and gstramer-plugins-bad packages):
    # /usr/bin/gst-launch-1.0 v4l2src device=/dev/video0 io-mode=2 ! image/jpeg, width=640, height=480, framerate=15/1 ! jpegparse ! jpegdec ! videoconvert ! video/x-raw, format=UYVY ! v4l2sink device=/dev/video1


    I am grabbing 640x480@15fps, you can check available formats/sizes/fps with
    # v4l2-ctl --list-formats-ext -d /dev/video0
    I am using raspberry pi 1 B and this command uses 50-70%. With 30fps there are a lot of dropped frames, and hyperion doesn't work with smaller image size. Due to this command, there is 50-70 ms delay (estimate for RPi)


    When making json conf file, it is important to set grabber device to /dev/video1 and:
    "standard" : "no-change"
    under "grabber-v4l2" section. When using HyperCon.jar to create json file the only options are 'PAL' and 'NTSC' so you'll need to change this setting in the text editor.


    I am using 4 for sizeDecimation and 1 for frameDecimation (since grabber already works on half the fps).

    Start hyperion now and it should work


    It might also be good advice to disable hyperion automatic start
    #systemctl disable hyperion
    If hyperion tries to start before /dev/video1 exists it will crash and try to start again and again....
    if hyperion starts before gstreamer command, gstreamer command will not be able to open /dev/video1 device and hyperion will not get any input.


  • Now we can use gstreamer to convert mjpeg stream from /dev/video0 into hyperion compatible stream on /dev/video1.
    I am using this command (needs gstreamer, gst-plugins-good and gstramer-plugins-bad packages):
    # /usr/bin/gst-launch-1.0 v4l2src device=/dev/video0 io-mode=2 ! image/jpeg, width=640, height=480, framerate=15/1 ! jpegparse ! jpegdec ! videoconvert ! video/x-raw, format=UYVY ! v4l2sink device=/dev/video1

    this really helps, tu

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!