Skip to content

Camera feed rotation with VAAPI acceleration is broken #1276

@giorgi1324

Description

@giorgi1324

Describe the bug

FFMPEG dies with following errors in the logs when I try to rotate the camera feed by 90 degrees.

wyze-bridge  | 06:12:31 [INFO][front-door-cam] Re-encoding using h264_vaapi [transpose='clock']
wyze-bridge  | 06:12:31 [INFO][front-door-cam][FFMPEG_CMD] ffmpeg -hide_banner -loglevel debug -fflags +flush_packets+nobuffer -flags +low_delay -thread_queue_size 8 -analyzeduration 32 -probesize 32 -hwaccel vaapi -f H264 -i pipe:0 -thread_queue_size 8 -analyzeduration 32 -probesize 32 -f aac -i /tmp/front-door-cam_audio.pipe -map 0:v -c:v h264_vaapi -filter:v transpose_vaapi=clock -b:v 3000k -coder 1 -bufsize 3000k -profile:v main -preset ultrafast -forced-idr 1 -force_key_frames expr:gte(t,n_forced*2) -map 1:a -c:a aac -filter:a volume=5,adelay=0|0 -fps_mode passthrough -flush_packets 1 -rtbufsize 1 -f tee [use_fifo=1:fifo_options=attempt_recovery=1\\\:drop_pkts_on_overflow=1:f=rtsp:rtsp_transport=tcp]rtsp://0.0.0.0:8554/front-door-cam
...

wyze-bridge  | Opening an output file: [use_fifo=1:fifo_options=attempt_recovery=1\\\:drop_pkts_on_overflow=1:f=rtsp:rtsp_transport=tcp]rtsp://0.0.0.0:8554/front-door-cam.
wyze-bridge  | [out#0/tee @ 0x7f2ca2d0c080] Codec AVOption preset (Encoding preset) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
wyze-bridge  | [out#0/tee @ 0x7f2ca2d0c080] Codec AVOption forced-idr (If forcing keyframes, force them as IDR frames.) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
wyze-bridge  | Successfully opened the file.
wyze-bridge  | [AVHWDeviceContext @ 0x7f2ca2d1ff00] No VA display found for any default device.
wyze-bridge  | Device creation failed: -22.
wyze-bridge  | No device available for decoder: device type vaapi needed for codec h264.
wyze-bridge  | Stream mapping:
wyze-bridge  |   Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_vaapi))
wyze-bridge  |   Stream #1:0 -> #0:1 (aac (native) -> aac (native))
wyze-bridge  | Device setup failed for decoder on input stream #0:0 : Invalid argument

For whatever reason, the FFMPEG included in the docker image is unable to perform hardware-accelerated rotation. Non-accelerated rotation works without issues.

Things to note:

  • I've passed through - /dev/dri/renderD128 to the container.
  • Hardware accelerated rotation works through Frigate container, when using go2rtc built in rotation transform.
  • I've tried the -hw flavor of the container, that one doesn't even go this far and complains about being unable to find libdrm.so.2.

My environment vars for the container are as follows:

- DEBUG_FFMPEG=True                                                                                                                                                                                                    - FFMPEG_LOGLEVEL=debug
- LOG_LEVEL=debug
- WB_AUTH=False
- MQTT_HOST=mosquitto:1883
- MQTT_AUTH=wyze-bridge:<...>
- MQTT_DTOPIC=homeassistant
- ON_DEMAND=False
- ENABLE_AUDIO=True
- AUDIO_CODEC=AAC
- H264_ENC=h264_vaapi
- V3=False
- ROTATE_CAM_FRONT_DOOR_CAM=0

vainfo, from what I understand, reports everything being normal inside of the container:

$ docker exec -it wyze-bridge bash
root@23463948b366:/app# vainfo
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
error: can't connect to X server!
libva info: VA-API version 1.17.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_17
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.17 (libva 2.12.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 23.1.1 ()
vainfo: Supported profile and entrypoints
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileNone                   : VAEntrypointStats
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointFEI
      VAProfileH264Main               : VAEntrypointEncSliceLP
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointFEI
      VAProfileH264High               : VAEntrypointEncSliceLP
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointFEI
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileVP8Version0_3          : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointFEI
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointEncSlice
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
root@23463948b366:/app#

Environment (if applicable)

  • Affected Camera(s): Wyze Cam v4
  • Affected Camera Firmware: 4.52.4.9887
  • Affected Bridge Version: [2.9.9-qsv]
  • Bridge type:
    • Docker Compose/Docker Run

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions