|
1 | 1 | # vhost-user-video
|
2 | 2 |
|
3 |
| -## Design |
| 3 | +## Synopsis |
| 4 | + vhost-user-video --socket-path <SOCKET_PATH> --backend <BACKEND> |
4 | 5 |
|
5 |
| -## Usage |
| 6 | +## Description |
| 7 | + A virtio-video device using the vhost-user protocol. |
| 8 | + |
| 9 | +## Arguments |
| 10 | + |
| 11 | +```text |
| 12 | + <BACKEND> |
| 13 | + Video backend to be used [possible values: null, v4l2-decoder] |
| 14 | +``` |
| 15 | + |
| 16 | +## Options |
| 17 | + |
| 18 | +```text |
| 19 | + -s, --socket-path <SOCKET_PATH> |
| 20 | + Unix socket to which a hypervisor connects to and sets up the control path with the device |
| 21 | +
|
| 22 | + -d, --v4l2-device <V4L2_DEVICE> |
| 23 | + Path to the video device file [default: /dev/video0] |
| 24 | +
|
| 25 | + -b, --backend <BACKEND> |
| 26 | + Video backend to be used [possible values: null, v4l2-decoder] |
| 27 | +
|
| 28 | + -h, --help |
| 29 | + Print help |
| 30 | +
|
| 31 | + -V, --version |
| 32 | + Print version |
| 33 | +``` |
| 34 | + |
| 35 | +## Limitations |
| 36 | + |
| 37 | +Currently this crate only supports v4l2 stateful decoder devices, and |
| 38 | +the intention is it will be used with Arm SoCs that implement stateful |
| 39 | +decode/encode devices such as Qcom Venus, RPi, MediaTek etc. |
| 40 | + |
| 41 | +Support for VAAPI or decoding via libavcodec or similar |
| 42 | +libraries is not implemented, but this could be added in the future |
| 43 | +through different video backends. |
| 44 | + |
| 45 | +## Features |
| 46 | + |
| 47 | +This crate is a work-in-progress. Also, the specification for this device is |
| 48 | +still a work-in-progress, so it requires and out-of-tree kernel on the |
| 49 | +guest. Currently, the vmm translates from virtio-video |
| 50 | +[v3](http://archive.lwn.net:8080/linux-media/6557912.4vTCxPXJkl@os-lin-dmo/T/) |
| 51 | +protocol and writes to a |
| 52 | +[v4l2 mem2mem stateful decoder device](https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/dev-decoder.html). |
| 53 | +The v3 of the specification was chosen as there is a |
| 54 | +virtio-video Linux frontend driver implementation available for testing. |
| 55 | + |
| 56 | +The primary goal so far is to enable development of virtio-video |
| 57 | +frontend driver using purely open source software. Using |
| 58 | +[vicodec](https://lwn.net/Articles/760650/) |
| 59 | +v4l2 stateful decoder on the host for testing allows a pure |
| 60 | +virtual environment for development and testing. |
6 | 61 |
|
7 | 62 | ## Working example
|
8 | 63 |
|
| 64 | +In this section we provide with some example commands to run the daemon |
| 65 | +and decode a video using vicodec. |
| 66 | + |
| 67 | +Guest Linux kernel modules: |
| 68 | + |
| 69 | +```text |
| 70 | +CONFIG_MEDIA_SUPPORT=y |
| 71 | +CONFIG_MEDIA_TEST_SUPPORT=y |
| 72 | +CONFIG_V4L_TEST_DRIVERS=y |
| 73 | +CONFIG_VIRTIO_VIDEO=y |
| 74 | +CONFIG_GDB_SCRIPTS=y |
| 75 | +CONFIG_DRM_VIRTIO_GPU=y |
| 76 | +``` |
| 77 | + |
| 78 | + |
| 79 | +Host kernel modules: |
| 80 | + |
| 81 | +```text |
| 82 | +CONFIG_MEDIA_SUPPORT=y |
| 83 | +CONFIG_MEDIA_TEST_SUPPORT=y |
| 84 | +CONFIG_V4L_TEST_DRIVERS=y |
| 85 | +CONFIG_VIDEO_VICODEC=y |
| 86 | +``` |
| 87 | + |
| 88 | +The daemon should be started first (video3 typically is the stateful video): |
| 89 | + |
| 90 | +```text |
| 91 | +host# vhost-user-video --socket-path=/tmp/video.sock --v4l2-device=/dev/video3 --backend=v4l2-decoder |
| 92 | +``` |
| 93 | + |
| 94 | +The QEMU invocation needs to create a chardev socket the device can |
| 95 | +use to communicate as well as share the guests memory over a memfd. |
| 96 | + |
| 97 | +```text |
| 98 | +host# qemu-system \ |
| 99 | + -device vhost-user-video-pci,chardev=video,id=video \ |
| 100 | + -chardev socket,path=/tmp/video.sock,id=video \ |
| 101 | + -m 4096 \ |
| 102 | + -object memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on \ |
| 103 | + -numa node,memdev=mem \ |
| 104 | + ... |
| 105 | +``` |
| 106 | + |
| 107 | +After booting, the device should be available at /dev/video0: |
| 108 | + |
| 109 | +```text |
| 110 | +guest# v4l2-ctl -d/dev/video0 --info |
| 111 | +Driver Info: |
| 112 | + Driver name : virtio-video |
| 113 | + Card type : |
| 114 | + Bus info : virtio:stateful-decoder |
| 115 | + Driver version : 6.1.0 |
| 116 | + Capabilities : 0x84204000 |
| 117 | + Video Memory-to-Memory Multiplanar |
| 118 | + Streaming |
| 119 | + Extended Pix Format |
| 120 | + Device Capabilities |
| 121 | + Device Caps : 0x04204000 |
| 122 | + Video Memory-to-Memory Multiplanar |
| 123 | + Streaming |
| 124 | + Extended Pix Format |
| 125 | +``` |
| 126 | + |
| 127 | +Example v4l2-ctl decode command: |
| 128 | + |
| 129 | +```text |
| 130 | +guest# v4l2-ctl -d0 -x width=640,height=480 -v width=640,height=480,pixelformat=YU12 \ |
| 131 | + --stream-mmap --stream-out-mmap --stream-from test_640_480-420P.fwht \ |
| 132 | + --stream-to out-test-640-480.YU12 |
| 133 | +``` |
| 134 | + |
| 135 | +Play the raw decoded video with ffplay or mplayer: |
| 136 | + |
| 137 | +```text |
| 138 | +guest# ffplay -loglevel warning -v info -f rawvideo -pixel_format yuv420p \ |
| 139 | + -video_size "640x480" ./out-test-640-480.YU12 |
| 140 | +guest# mplayer -demuxer rawvideo -rawvideo \ |
| 141 | + format=i420:w=640:h=480:fps=25 out-test-640-480.YU12 |
| 142 | +``` |
| 143 | + |
| 144 | +Enable v4l2 debug in virtio-video driver: |
| 145 | + |
| 146 | +```text |
| 147 | +# echo 0x1f > /sys/class/video4linux/videoX/dev_debug |
| 148 | +``` |
| 149 | + |
9 | 150 | ## License
|
10 | 151 |
|
11 | 152 | This project is licensed under either of
|
|
0 commit comments