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

RPi + Other Software Virtual capture device /dev/video0

Discussion in 'Software Support' started by Hwulex, 17 November 2017.

  1. Hwulex

    Hwulex New Member

    Messages:
    4
    Hardware:
    RPi1/Zero, RPi2, 32/64bit, +PhilipsHue
    Been a very happy Hyperion ambilight user for several years now but my AV setup recently changed thus my light config also needs to.

    For experimental, but necessary reasons, I am manipulating my capture feed finally exporting it as a video output device /dev/video0 using v4l2loopback and ffmpeg. The manipulated feed works great and I can capture proper screengrabs from it using streamer on the command line. It is properly encoded as UYVY which is a compatible format for Hyperion.

    My problem is that if I try to grab a screenshot from Hypercon I get

    ssh in: hyperion-v4l2:
    ssh in: version : V1.03.3 (brindosch-2fbbcff/2f01dfa-1495880388
    ssh in: build time: Jun 3 2017 02:06:37
    ssh out: VIDIOC_S_STD ERROR 25, Inappropriate ioctl for device

    From my searches, the usual answer is that "chipset is not supported" however this is a virtual device and has no "chipset". Is there any way for me to just "plug in" this virtual capture feed in to Hyperion?

    I know that some of my v42l-ctl --all output (below) is different from a regular USBTV007 device output. Are there essential pieces I need to match up for it to work maybe?

    Thanks.


    Device stream
    $ python vid.py | ffmpeg -f rawvideo -s 640x480 -pix_fmt bgr24 -i - -an -f v4l2 -pix_fmt uyvy422 /dev/video0

    ffmpeg version 3.2.8-1~deb9u1 Copyright (c) 2000-2017 the FFmpeg developers
    built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1) 20170516
    configuration: --prefix=/usr --extra-version='1~deb9u1' --toolchain=hardened --libdir=/usr/lib/arm-linux-gnueabihf --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
    libavutil 55. 34.101 / 55. 34.101
    libavcodec 57. 64.101 / 57. 64.101
    libavformat 57. 56.101 / 57. 56.101
    libavdevice 57. 1.100 / 57. 1.100
    libavfilter 6. 65.100 / 6. 65.100
    libavresample 3. 1. 0 / 3. 1. 0
    libswscale 4. 2.100 / 4. 2.100
    libswresample 2. 3.100 / 2. 3.100
    libpostproc 54. 1.100 / 54. 1.100
    Input #0, rawvideo, from 'pipe:':
    Duration: N/A, start: 0.000000, bitrate: 184320 kb/s
    Stream #0:0: Video: rawvideo (BGR[24] / 0x18524742), bgr24, 640x480, 184320 kb/s, 25 tbr, 25 tbn, 25 tbc
    Output #0, v4l2, to '/dev/video0':
    Metadata:
    encoder : Lavf57.56.101
    Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 640x480, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
    encoder : Lavc57.64.101 rawvideo
    Stream mapping:
    Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))

    frame= 69 fps= 10 q=-0.0 size=N/A time=00:00:02.76 bitrate=N/A speed=0.41x
    Screen capture
    streamer -f jpeg -s 640x480 -o out.jpeg

    v4l2-ctl --all output
    Driver Info (not using libv4l2):
    Driver name : v4l2 loopback
    Card type : Dummy video device (0x0000)
    Bus info : platform:v4l2loopback-000
    Driver version: 4.9.59
    Capabilities : 0x85208003
    Video Capture
    Video Output
    Video Memory-to-Memory
    Read/Write
    Streaming
    Extended Pix Format
    Device Capabilities
    Device Caps : 0x85208003
    Video Capture
    Video Output
    Video Memory-to-Memory
    Read/Write
    Streaming
    Extended Pix Format
    Device Capabilities
    Priority: 0
    Video input : 0 (loopback: ok)
    Video output: 0 (loopback in)
    Format Video Capture:
    Width/Height : 640/480
    Pixel Format : 'UYVY'
    Field : None
    Bytes per Line : 1280
    Size Image : 614400
    Colorspace : sRGB
    Transfer Function : Default
    YCbCr/HSV Encoding: Default
    Quantization : Default
    Flags :
    Format Video Output:
    Width/Height : 640/480
    Pixel Format : 'UYVY'
    Field : None
    Bytes per Line : 1280
    Size Image : 614400
    Colorspace : sRGB
    Transfer Function : Default
    YCbCr/HSV Encoding: Default
    Quantization : Default
    Flags :
    Streaming Parameters Video Capture:
    Frames per second: 30.000 (30/1)
    Read buffers : 8
    Streaming Parameters Video Output:
    Frames per second: 30.000 (30/1)
    Write buffers : 8

    User Controls

    keep_format (bool) : default=0 value=0
    sustain_framerate (bool) : default=0 value=0
    timeout (int) : min=0 max=100000 step=1 default=0 value=0
    timeout_image_io (bool) : default=0 value=0

     

    Attached Files:

    Last edited: 17 November 2017
  2. Hwulex

    Hwulex New Member

    Messages:
    4
    Hardware:
    RPi1/Zero, RPi2, 32/64bit, +PhilipsHue
    Nobody has any experience using a virtual or different video0 source in Hyperion? Starting to trawl the Hyperion source code to see if there's something I can tinker with to get it working.
     
  3. TPmodding

    TPmodding Administrator Staff Member Administrator

    Messages:
    826
    Hardware:
    RPi1/Zero, RPi2, RPi3, +Arduino
    i had it a few years ago...a user in another forum used v4l2-loopback for multiple instances in hyperion...he used gstreamer and that was his command i think
    Code:
    /usr/bin/gst-launch-1.0 v4l2src device=/dev/video0 io-mode=2 ! video/x-raw,format=UYVY, framerate=30000/1001,width=240,height=192 ! deinterlace ! v4l2sink device=/dev/video1
    edit: its only german,but it was .bismarck
    https://forum-raspberrypi.de/forum/...llenumschaltung-milhouse-31-10-15-2/?pageNo=1
     
  4. ZenDog

    ZenDog New Member

    Messages:
    2
    Hardware:
    RPi3
    @Hwulex
    I have come as far as you with streaming to the raspberry pi. Also, I encountered the same errors.
    sh in: Dec 07 06:48:54 hyperion hyperiond[834]: BLACKBORDER INFO: threshold set to 0.45 (115)
    ssh in: Dec 07 06:48:54 hyperion hyperiond[834]: BLACKBORDER INFO: mode:default
    ssh in: Dec 07 06:48:54 hyperion hyperiond[834]: started
    ssh in: Dec 07 06:48:54 hyperion hyperiond[834]: INFO: Json server created and started on port 19444
    ssh in: Dec 07 06:48:54 hyperion hyperiond[834]: INFO: Proto server created and started on port 19445
    ssh in: Dec 07 06:48:54 hyperion hyperiond[834]: terminate called after throwing an instance of 'std::runtime_error'
    ssh in: Dec 07 06:48:54 hyperion hyperiond[834]: what(): VIDIOC_S_STD ERROR 25, Inappropriate ioctl for device
    ssh in: Dec 07 06:48:54 hyperion systemd[1]: hyperion.service: Main process exited, code=killed, status=6/ABRT
    ssh in: Dec 07 06:48:54 hyperion systemd[1]: hyperion.service: Unit entered failed state.
    ssh in: Dec 07 06:48:54 hyperion systemd[1]: hyperion.service: Failed with result 'signal'.

    Did you find a solution?
     
  5. penfold42

    penfold42 Moderator Developer

    Messages:
    661
    Hardware:
    RPi1/Zero, RPi2, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
    My guess is that it’s trying to set pal/ntsc

    From memory Hyperion.ng has a “no change” option
     
  6. ZenDog

    ZenDog New Member

    Messages:
    2
    Hardware:
    RPi3
    I found a better solution for streaming and it is fast :)

    I use ffmpeg to stream my desktop via UDP:
    ffmpeg -f avfoundation -i "1" -s 320x240 -r 25 -c:v mpeg2video -preset superfast -pix_fmt yuv420p -tune zerolatency -f mpegts udp://xxx.xxx.xxx.xxx:1234

    and on the raspberry pi side, I use omxplayer to play to hdmi. Note, that you do not need X11 or any windows based system. It works like charm for headless raspberries :)
    Here the omxplayer command:
    omxplayer -o hdmi --live udp://192.168.178.20:1234

    Note that the parameter --live is important for quick processing.

    Btw, you need to buy a mpeg2 license for the raspberry pi, which will cost you around 2,8€.