LINUX.ORG.RU

Как использовать vdpau в ffmpeg?

 ,


0

3

Приветствую.

Есть usb камера

# v4l2-ctl --all -d 0
Driver Info (not using libv4l2):
    Driver name   : uvcvideo
    Card type     : CS-USB-IMX307: UVC Camera
    Bus info      : usb-1c1d000.usb-1
    Driver version: 4.14.111
    Capabilities  : 0x84200001
        Video Capture
        Streaming
        Extended Pix Format
        Device Capabilities
    Device Caps   : 0x04200001
        Video Capture
        Streaming
        Extended Pix Format
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:
    Width/Height      : 1920/1080
    Pixel Format      : 'H264'
    Field             : None
    Bytes per Line    : 3840
    Size Image        : 4147200
    Colorspace        : sRGB
    Transfer Function : Default
    YCbCr Encoding    : Default
    Quantization      : Default
    Flags             :
Crop Capability Video Capture:
    Bounds      : Left 0, Top 0, Width 1920, Height 1080
    Default     : Left 0, Top 0, Width 1920, Height 1080
    Pixel Aspect: 1/1
Selection: crop_default, Left 0, Top 0, Width 1920, Height 1080
Selection: crop_bounds, Left 0, Top 0, Width 1920, Height 1080
Streaming Parameters Video Capture:
    Capabilities     : timeperframe
    Frames per second: 30.000 (30/1)
    Read buffers     : 0
                     brightness (int)    : min=0 max=100 step=1 default=50 value=50
                       contrast (int)    : min=0 max=100 step=1 default=50 value=50
                     saturation (int)    : min=0 max=100 step=1 default=50 value=50
                            hue (int)    : min=0 max=100 step=1 default=50 value=50
error 5 getting ctrl White Balance Temperature, Auto

с такими потоками

# v4l2-ctl --list-formats-ext -d 0
ioctl: VIDIOC_ENUM_FMT
    Index       : 0
    Type        : Video Capture
    Pixel Format: 'YUYV'
    Name        : YUYV 4:2:2
        Size: Discrete 640x360
         Interval: Discrete 0.033s (30.000 fps)

    Index       : 1
    Type        : Video Capture
    Pixel Format: 'MJPG' (compressed)
    Name        : Motion-JPEG
        Size: Discrete 640x360
         Interval: Discrete 0.033s (30.000 fps)
        Size: Discrete 1280x720
         Interval: Discrete 0.033s (30.000 fps)
        Size: Discrete 1920x1080
         Interval: Discrete 0.033s (30.000 fps)

    Index       : 2
    Type        : Video Capture
    Pixel Format: 'H264' (compressed)
    Name        : H.264
        Size: Discrete 640x360
         Interval: Discrete 0.033s (30.000 fps)
        Size: Discrete 1280x720
         Interval: Discrete 0.033s (30.000 fps)
        Size: Discrete 1920x1080
         Interval: Discrete 0.033s (30.000 fps)

есть ффмпег с поддержкой декодера на вдпау

# ./ffmpeg-ubrv -codecs | grep vdpau | grep 264
ffmpeg version git-2015-01-22-f86a076 Copyright (c) 2000-2014 the FFmpeg developers
  built on Jul 18 2024 12:09:53 with gcc 5.4.0 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.12) 20160609
  configuration: --prefix=/usr --enable-nonfree --enable-gpl --enable-version3 --enable-vdpau --enable-libx264 --enable-libv4l2 --disable-doc
  libavutil      54.  6.100 / 54.  6.100
  libavcodec     56.  0.101 / 56.  0.101
  libavformat    56.  2.100 / 56.  2.100
  libavdevice    56.  0.100 / 56.  0.100
  libavfilter     5.  0.102 /  5.  0.102
  libswscale      3.  0.100 /  3.  0.100
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  0.100 / 53.  0.100
 DEV.LS h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_vdpau ) (encoders: libx264 libx264rgb cedrus264 )

пытаюсь проверить декодер как

# VDPAU_DRIVER=sunxi ./ffmpeg-ubrv -f v4l2 -input_format h264 -video_size 1920x1080 -pix_fmt yuyv422 -c:v h264_vdpau -i /dev/video0 -f null /dev/null

при поступлении опорного кадра падает с ошибкой

[video4linux2,v4l2 @ 0xf4c480] decoding for stream 0 failed
[video4linux2,v4l2 @ 0xf4c480] Could not find codec parameters for stream 0 (Video: h264 (Baseline), 1920x1080, -5 kb/s): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
/dev/video0: could not find codec parameters
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: h264 (Baseline), 1920x1080, -5 kb/s, 30 fps, 30 tbr, 1000k tbn, 2000k tbc
[buffer @ 0x1157c00] Unable to parse option value "-1" as pixel format
    Last message repeated 1 times
[buffer @ 0x1157c00] Error setting option pix_fmt to value -1.
[graph 0 input from stream 0:0 @ 0xf45620] Error applying options to the filter.
Error opening filters!

к слову использую

# ls -l /usr/lib/arm-linux-gnueabihf/vdpau/libvdpau_sunxi.so*
lrwxrwxrwx 1 root root 19 Jul 19 09:47 /usr/lib/arm-linux-gnueabihf/vdpau/libvdpau_sunxi.so -> libvdpau_sunxi.so.1
lrwxrwxrwx 1 root root 28 Jul 19 08:40 /usr/lib/arm-linux-gnueabihf/vdpau/libvdpau_sunxi.so.1 -> /home/pi/libvdpau_sunxi.so.1

но запрос не показывает какой либой пользуется

# vdpauinfo
vdpauinfo: cannot connect to X server
★★★

Последнее исправление: Dimez (всего исправлений: 1)
Ответ на: комментарий от anonymous

ну варианты указать -pix_fmt yuv420p или как определяет штатный декодер как

-pix_fmt yuvj420p

Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 4163444.547420, bitrate: N/A
    Stream #0:0: Video: h264 (Baseline), yuvj420p(pc, bt709), 1920x1080, -5 kb/s, 30 fps, 30 tbr, 1000k tbn, 2000k tbc

приводит к той же ошибке

похоже какая то беда именно с декодером h264_vdpau

wolverin ★★★
() автор топика
Ответ на: комментарий от anonymous

один из разработчиков аппаратного кодирования на H3 говорит через через иксы у него работало как

DISPLAY=:1 ffmpeg -hwaccel vdpau -i Big_Buck_Bunny_720_10s_2MB.mp4 -pix_fmt nv12 -c:v cedrus264 stream.h264

но у меня ошибка

# vdpauinfo
vdpauinfo: cannot connect to X server
wolverin ★★★
() автор топика
Ответ на: комментарий от wolverin
./ffmpeg-ubrv -f v4l2 -input_format h264 -video_size 1920x1080  -hwaccel vdpau -i /dev/video0 -f null /dev/null
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 4164201.423262, bitrate: N/A
    Stream #0:0: Video: h264 (Baseline), yuvj420p(pc, bt709), 1920x1080, -5 kb/s, 30 fps, 30 tbr, 1000k tbn, 2000k tbc
Output #0, null, to '/dev/null':
  Metadata:
    encoder         : Lavf56.2.100
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuvj420p, 1920x1080, q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc
    Metadata:
      encoder         : Lavc56.0.101 rawvideo
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Cannot open the X11 display .
VDPAU init failed for stream #0:0.
vdpau hwaccel requested for input stream #0:0, but cannot be initialized.
[video4linux2,v4l2 @ 0xf4c420] Some buffers are still owned by the caller on close.

wolverin ★★★
() автор топика
Ответ на: комментарий от wolverin

хе хе, по этой ошибке оказывается надо было export DISPLAY=:1

root@NanoPi-NEO-Core:~# export VDPAU_DRIVER=sunxi
root@NanoPi-NEO-Core:~# vdpauinfo
display: :1   screen: 0
[VDPAU SUNXI] VE version 0x1680 opened
[VDPAU SUNXI] OSD disabled!
API version: 1
Information string: sunxi VDPAU Driver

Video surface:

name   width height types
-------------------------------------------
420     8192  8192  NV12 YV12

Decoder capabilities:

name                        level macbs width height
----------------------------------------------------
MPEG1                           0 32400  3840  2160
MPEG2_SIMPLE                    3 32400  3840  2160
MPEG2_MAIN                      3 32400  3840  2160
H264_BASELINE                  51 32400  3840  2160
H264_MAIN                      51 32400  3840  2160
H264_HIGH                      51 32400  3840  2160
VC1_SIMPLE                     --- not supported ---
VC1_MAIN                       --- not supported ---
VC1_ADVANCED                   --- not supported ---
MPEG4_PART2_SP                  5 32400  3840  2160
MPEG4_PART2_ASP                 5 32400  3840  2160
DIVX4_QMOBILE                  --- not supported ---
DIVX4_MOBILE                   --- not supported ---
DIVX4_HOME_THEATER             --- not supported ---
DIVX4_HD_1080P                 --- not supported ---
DIVX5_QMOBILE                  --- not supported ---
DIVX5_MOBILE                   --- not supported ---
DIVX5_HOME_THEATER             --- not supported ---
DIVX5_HD_1080P                 --- not supported ---
H264_CONSTRAINED_BASELINE      51 32400  3840  2160
H264_EXTENDED                  --- not supported ---
H264_PROGRESSIVE_HIGH          --- not supported ---
H264_CONSTRAINED_HIGH          51 32400  3840  2160
H264_HIGH_444_PREDICTIVE       --- not supported ---
HEVC_MAIN                      150 32400  3840  2160
HEVC_MAIN_10                   --- not supported ---
HEVC_MAIN_STILL                --- not supported ---
HEVC_MAIN_12                   --- not supported ---
HEVC_MAIN_444                  --- not supported ---

Output surface:

name              width height nat types
----------------------------------------------------
B8G8R8A8          8192  8192    -
R8G8B8A8          8192  8192    -

Bitmap surface:

name              width height
------------------------------
B8G8R8A8          8192  8192
R8G8B8A8          8192  8192

Video mixer:

feature name                    sup
------------------------------------
DEINTERLACE_TEMPORAL             -
DEINTERLACE_TEMPORAL_SPATIAL     -
INVERSE_TELECINE                 -
NOISE_REDUCTION                  -
SHARPNESS                        -
LUMA_KEY                         -
HIGH QUALITY SCALING - L1        -
HIGH QUALITY SCALING - L2        -
HIGH QUALITY SCALING - L3        -
HIGH QUALITY SCALING - L4        -
HIGH QUALITY SCALING - L5        -
HIGH QUALITY SCALING - L6        -
HIGH QUALITY SCALING - L7        -
HIGH QUALITY SCALING - L8        -
HIGH QUALITY SCALING - L9        -

parameter name                  sup      min      max
-----------------------------------------------------
VIDEO_SURFACE_WIDTH              y         0     8192
VIDEO_SURFACE_HEIGHT             y         0     8192
CHROMA_TYPE                      y
LAYERS                           y         0        0

attribute name                  sup      min      max
-----------------------------------------------------
BACKGROUND_COLOR                 -
CSC_MATRIX                       -
NOISE_REDUCTION_LEVEL            -
SHARPNESS_LEVEL                  -
LUMA_KEY_MIN_LUMA                -
LUMA_KEY_MAX_LUMA                -

wolverin ★★★
() автор топика
Ответ на: комментарий от wolverin

так вроде ЧТО-ТО работает, но по факту хз чем занято, видео нет на сервере, загрузка цпу нулевая

./ffmpeg-ubrv -f v4l2 -input_format h264 -video_size 1280x720 -hwaccel vdpau -i /dev/video0 -c:v cedrus264 -pix_fmt nv12 -f rtsp -rtsp_transport tcp rtsp://....ru:/123456789
ffmpeg version git-2015-01-22-f86a076 Copyright (c) 2000-2014 the FFmpeg developers
  built on Jul 18 2024 12:09:53 with gcc 5.4.0 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.12) 20160609
  configuration: --prefix=/usr --enable-nonfree --enable-gpl --enable-version3 --enable-vdpau --enable-libx264 --enable-libv4l2 --disable-doc
  libavutil      54.  6.100 / 54.  6.100
  libavcodec     56.  0.101 / 56.  0.101
  libavformat    56.  2.100 / 56.  2.100
  libavdevice    56.  0.100 / 56.  0.100
  libavfilter     5.  0.102 /  5.  0.102
  libswscale      3.  0.100 /  3.  0.100
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  0.100 / 53.  0.100
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 4165345.507402, bitrate: N/A
    Stream #0:0: Video: h264 (Baseline), yuvj420p(pc, bt709), 1280x720, -5 kb/s, 30 fps, 30 tbr, 1000k tbn, 2000k tbc
[swscaler @ 0xf3f6e0] deprecated pixel format used, make sure you did set range correctly
[VDPAU SUNXI] VE version 0x1680 opened.
[rtp @ 0x101e2f0] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
Output #0, rtsp, to 'rtsp://....ru:/123456789':
  Metadata:
    encoder         : Lavf56.2.100
    Stream #0:0: Video: h264 (cedrus264), nv12, 1280x720, q=2-31, 200 kb/s, 30 fps, 90k tbn, 30 tbc
    Metadata:
      encoder         : Lavc56.0.101 cedrus264
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (cedrus264))
Press [q] to stop, [?] for help
[VDPAU SUNXI] VE version 0x1680 opened
[VDPAU SUNXI] OSD disabled!
Input stream #0:0 frame changed from size:1280x720 fmt:yuvj420p to size:1280x720 fmt:yuv420p
frame=   41 fps=1.0 q=30.0 size=N/A time=00:00:00.00 bitrate=N/A dup=19 drop=1

wolverin ★★★
() автор топика
Последнее исправление: wolverin (всего исправлений: 2)
Ответ на: комментарий от wolverin

если кто вдруг решит еще поюзать этот мертвый проект, то вот полностью что мне рассказали (где потребовалась мне последняя часть про иксы)

1 sudo apt-get install libpixman-1-dev
2 sudo apt install libvdpau-dev
3 git clone https://github.com/linux-sunxi/libcedrus
4 cd libcedrus
5 sudo make && sudo make install
6 git clone https://github.com/linux-sunxi/libvdpau-sunxi,
7 cd libvdpau-sunxi
8 sudo make && sudo make install
9 ldconfig
10 export VDPAU_DRIVER=sunxi
11 apt-get install xvfb
12 apt-get install x11-xkb-utils
13 apt-get install xserver-xorg-core
14 Xvfb :1 -screen 0 1280x720x30 -fbdir /var/tmp&
wolverin ★★★
() автор топика