1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

v4l2 grabber : 'MJPG' pixel format support

Discussion in 'Hyperion Hardware' started by Frank_V, 4 August 2017.

  1. Frank_V

    Frank_V New Member

    Is there anything i can do to get this to work
    or do i need to find another one ?

    Thank you
  2. Akriss

    Akriss Active Member

    RPi1/Zero, RPi2, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
  3. Ivan

    Ivan New Member

    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 [email protected], 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.