homebridge/ffmpeg-for-homebridge

No HW acceleration with ffmpeg-for-homebridge but ok with ubuntu ffmpeg

zoic21 opened this issue · 1 comments

Describe The Bug:

I'am in docker on Synology DS218+ with home bridge docker. I use homebrige unifi protect plugin, no problem with it. My issue is with hardware acceleration.

If I install ffmpeg (apt install ffmpeg) no problem hardware acceleration work but this ffmpeg version (4.X) is to old and unifi protect plugin don't work.

So I moved to ffmpeg-for-hombridge, it's work but without HW acceleration (on same docker)

To Reproduce:

Install homebridge docker on Synology than install ffmpeg-for-homebridge and try to use ffmpeg with hw acceleration
ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -t 1 -f lavfi -i color=black:1920x1080 -c:v libx264 -f null -, I got :

ffmpeg -hwaccel vaapi -t  1 -f lavfi -i color=black:1920x
1080 -c:v libx264 -f null -                                                      
ffmpeg version 6.0-homebridge-alpine-x86_64-static Copyright (c) 2000-2023 the FF
mpeg developers                                                                  
  built with gcc 12.2.1 (Alpine 12.2.1_git20220924-r10) 20220924                 
  configuration: --enable-hardcoded-tables --enable-nonfree --enable-gpl --enable
-hardcoded-tables --enable-hardcoded-tables --enable-openssl --enable-libdav1d --
enable-libsvtav1 --enable-libx264 --enable-libx265 --enable-libvpx --enable-libxv
id --enable-libvidstab --enable-libaom --enable-libzimg --enable-lv2 --enable-lib
opencore_amrnb --enable-libopencore_amrwb --enable-libmp3lame --enable-libopus --
enable-libvorbis --enable-libtheora --enable-libfdk-aac --enable-libwebp --enable
-libsrt --enable-libvpl --enable-vaapi --disable-ffnvcodec --enable-amf --disable
-debug --disable-shared --enable-pthreads --enable-static --enable-version3 --ext
ra-cflags='-I/build/workspace/include -I/build/workspace/include/lilv-0' --extra-
ldexeflags=-static --extra-ldflags=-L/build/workspace/lib --extra-libs='-ldl -lpt
hread -lm -lz' --pkgconfigdir=/build/workspace/lib/pkgconfig --pkg-config-flags=-
-static --prefix=/build/workspace --extra-version=homebridge-alpine-x86_64-static
  libavutil      58.  2.100 / 58.  2.100                                         
  libavcodec     60.  3.100 / 60.  3.100                                         
  libavformat    60.  3.100 / 60.  3.100                                         
  libavdevice    60.  1.100 / 60.  1.100                                         
  libavfilter     9.  3.100 /  9.  3.100                                         
  libswscale      7.  1.100 /  7.  1.100                                         
  libswresample   4. 10.100 /  4. 10.100                                         
  libpostproc    57.  1.100 / 57.  1.100                                         
Input #0, lavfi, from 'color=black:1920x1080':                                   
  Duration: N/A, start: 0.000000, bitrate: N/A                                   
  Stream #0:0: Video: wrapped_avframe, yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 25 
fps, 25 tbr, 25 tbn                                                              
[AVHWDeviceContext @ 0x7f70d285fb00] No VA display found for any default device. 
Device creation failed: -22.                                                     
No device available for decoder: device type vaapi needed for codec wrapped_avfra
me.                                                                              
Stream mapping:                                                                  
  Stream #0:0 -> #0:0 (wrapped_avframe (native) -> h264 (libx264))               
Device setup failed for decoder on input stream #0:0 : Invalid argument

Expected behavior:

I expect ffmpeg work without error, with built-in ubuntu ffmpeg :

/usr/bin/ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/r
enderD128 -t  1 -f lavfi -i color=black:1920x1080 -c:v libx264 -f null -         
ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg develope
rs                                                                               
  built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)                                    
  configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=harde
ned --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --a
rch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enab
le-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-li
bfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-lib
gsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg 
--enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --ena
ble-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-
libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei
0r --enable-libx264 --enable-shared                                              
  libavutil      56. 70.100 / 56. 70.100                                         
  libavcodec     58.134.100 / 58.134.100                                         
  libavformat    58. 76.100 / 58. 76.100                                         
  libavdevice    58. 13.100 / 58. 13.100                                         
  libavfilter     7.110.100 /  7.110.100                                         
  libswscale      5.  9.100 /  5.  9.100                                         
  libswresample   3.  9.100 /  3.  9.100                                         
  libpostproc    55.  9.100 / 55.  9.100                                         
Input #0, lavfi, from 'color=black:1920x1080':                                   
  Duration: N/A, start: 0.000000, bitrate: N/A                                   
  Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080 [SAR 1:1 D
AR 16:9], 25 tbr, 25 tbn, 25 tbc                                                 
Stream mapping:                                                                  
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))                      
Press [q] to stop, [?] for help                                                  
[libx264 @ 0x55a895c59140] using SAR=1/1                                         
[libx264 @ 0x55a895c59140] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2    
[libx264 @ 0x55a895c59140] profile High, level 4.0, 4:2:0, 8-bit      
Output #0, null, to 'pipe:':                                                     
  Metadata:                                                                      
    encoder         : Lavf58.76.100                                              
  Stream #0:0: Video: h264, yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q
=2-31, 25 fps, 25 tbn                                                            
    Metadata:                                                                    
      encoder         : Lavc58.134.100 libx264                                   
    Side data:                                                                   
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A              
frame=   25 fps= 22 q=-1.0 Lsize=N/A time=00:00:00.92 bitrate=N/A speed=0.813x
video:3kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing over
head: unknown                                                                    
[libx264 @ 0x55a895c59140] frame I:1     Avg QP: 9.00  size:  1158               
[libx264 @ 0x55a895c59140] frame P:6     Avg QP:10.17  size:    76               
[libx264 @ 0x55a895c59140] frame B:18    Avg QP:12.67  size:    69               
[libx264 @ 0x55a895c59140] consecutive B-frames:  4.0%  0.0%  0.0% 96.0%         
[libx264 @ 0x55a895c59140] mb I  I16..4: 100.0%  0.0%  0.0%                      
[libx264 @ 0x55a895c59140] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:  0.0%  0.0%  
0.0%  0.0%  0.0%    skip:100.0%                                                  
[libx264 @ 0x55a895c59140] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.0%  0.0%  
0.0%  direct: 0.0%  skip:100.0%                                                  
[libx264 @ 0x55a895c59140] 8x8 transform intra:0.0%                              
[libx264 @ 0x55a895c59140] coded y,uvDC,uvAC intra: 0.0% 0.0% 0.0% inter: 0.0% 0.
0% 0.0%                                                                          
[libx264 @ 0x55a895c59140] i16 v,h,dc,p: 99%  0%  1%  0%                         
[libx264 @ 0x55a895c59140] i8c dc,h,v,p: 100%  0%  0%  0%                        
[libx264 @ 0x55a895c59140] Weighted P-Frames: Y:0.0% UV:0.0%                     
[libx264 @ 0x55a895c59140] kb/s:22.78      

ffmpeg output:

ffmpeg version 6.0-homebridge-alpine-x86_64-static Copyright (c) 2000-2023 the FF
mpeg developers                                                                  
  built with gcc 12.2.1 (Alpine 12.2.1_git20220924-r10) 20220924                 
  configuration: --enable-hardcoded-tables --enable-nonfree --enable-gpl --enable
-hardcoded-tables --enable-hardcoded-tables --enable-openssl --enable-libdav1d --
enable-libsvtav1 --enable-libx264 --enable-libx265 --enable-libvpx --enable-libxv
id --enable-libvidstab --enable-libaom --enable-libzimg --enable-lv2 --enable-lib
opencore_amrnb --enable-libopencore_amrwb --enable-libmp3lame --enable-libopus --
enable-libvorbis --enable-libtheora --enable-libfdk-aac --enable-libwebp --enable
-libsrt --enable-libvpl --enable-vaapi --disable-ffnvcodec --enable-amf --disable
-debug --disable-shared --enable-pthreads --enable-static --enable-version3 --ext
ra-cflags='-I/build/workspace/include -I/build/workspace/include/lilv-0' --extra-
ldexeflags=-static --extra-ldflags=-L/build/workspace/lib --extra-libs='-ldl -lpt
hread -lm -lz' --pkgconfigdir=/build/workspace/lib/pkgconfig --pkg-config-flags=-
-static --prefix=/build/workspace --extra-version=homebridge-alpine-x86_64-static
  libavutil      58.  2.100 / 58.  2.100                                         
  libavcodec     60.  3.100 / 60.  3.100                                         
  libavformat    60.  3.100 / 60.  3.100                                         
  libavdevice    60.  1.100 / 60.  1.100                                         
  libavfilter     9.  3.100 /  9.  3.100                                         
  libswscale      7.  1.100 /  7.  1.100                                         
  libswresample   4. 10.100 /  4. 10.100                                         
  libpostproc    57.  1.100 / 57.  1.100                                         
Hyper fast Audio and Video encoder                                               
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfil
e}...                                                                            
                                                                                 
Use -h to get full help or, even better, run 'man ffmpeg' 

Environment:

  • Operating System: Docker on synology

Please don't conflate homebridge-unifi-protect with ffmpeg-for-homebridge.

Hardware acceleration in ffmpeg-for-homebridge is experimental and isn't guaranteed to work. It is a work in progress.

We're aware of the issues and are continuing to evolve ffmpeg-for-homebridge. If you want hardware acceleration on non-Apple or Raspberry Pi hardware, you can build your own or use the native capabilities provided.

The situation will improve over time. Thanks.