Jump to content

Enable hardware acceleration on FreeBSD


Duffyx

Recommended Posts

On 11/23/2020 at 1:47 PM, Duffyx said:

You are confusing two directories let me explain, from within the jail you need to see the bottom list of files in /dev/dri.
You can create the symlink of render0 to card0 with the post init script as I showed. These are the hardware nodes ffmpeg uses for VAAPI.




root@emby:/dev/dri # ls -l
lrwxr-xr-x  1 root  wheel   8 Nov 16 16:17 card0 -> ../drm/0
lrwxr-xr-x  1 root  wheel   5 Nov 16 16:17 render0 -> card0
lrwxr-xr-x  1 root  wheel  10 Nov 16 16:17 renderD128 -> ../drm/128

Then we have the directory that takes care of hackishly feeding the devices in ffdetect for detection. Here you can create the symlink once, from within the jail. It does not need to be created every time because this is written on the local filesystem and is not part of devfs like the render node above. I also noticed you had weird permissions on the files extracted (group: staff?).




root@emby:/sys/bus/pci/devices/pci0000_00/drm # ls -l
-rwxr-xr-x  1 root  wheel   9 Oct 31 13:15 card0
lrwxr-xr-x  1 root  wheel   5 Oct 31 13:53 render0 -> card0

For the pci-ids error you need the following (install the package pciids, misc/pciids), we need to emulate the linux location of the pci.ids file.




root@emby:/usr/share/hwdata # ls -l
lrwxr-xr-x   1 root  wheel  31 Oct 31 10:18 pci.ids -> /usr/local/share/pciids/pci.ids

EDIT: I reuploaded the tar archive to this post.

sys.xz 12.5 kB · 2 downloads

After rebooting emby and the server I get the following within the jail:

image.png.916fa9186b9d5c963fe04e698b361ec7.png

I didn't create the symlink within the jail:

image.png

I already have pciids installed:

image.png.dd0684ec3650aed5ad61a1601fc42bbd.png

However, without fixing the pci the HW decoding has started working:

 

image.png.00118e26de6b57320ffe742818c1b8bd.png

and the vaenc does return more correctly; however, it still has the pci error:

root@emby_2:/usr/local/lib/emby-server/bin # su -m emby -c "./ffdetect vaenc"
ffdetect version 4.3.0-emby_2020_05_23 Copyright (c) 2018-2019 softworkz for Emby LLC
  built with FreeBSD clang version 8.0.1 (tags/RELEASE_801/final 366581) (based on LLVM 8.0.1)
  configuration: --cc=clang --prefix=/usr/home/embybuilder/x64_freebsd12/ffmpeg-x64_freebsd12/staging --disable-amf --disable-debug --disable-doc --disable-ffplay --disable-vdpau --disable-xlib --enable-fontconfig --enable-gnutls --enable-gpl --enable-iconv --enable-libass --enable-libdav1d --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libzvbi --enable-pic --enable-version3 --enable-vaapi --arch=x86_64 --enable-shared --disable-static
  WARNING: library configuration mismatch
  avutil      configuration: --prefix=/usr/local --mandir=/usr/local/man --datadir=/usr/local/share/ffmpeg --pkgconfigdir=/usr/local/libdata/pkgconfig --enable-shared --enable-pic --enable-gpl --enable-avresample --cc=cc --cxx=c++ --disable-alsa --disable-libopencore-amrnb --disable-libopencore-amrwb --disable-libaom --disable-libaribb24 --enable-asm --enable-libass --disable-libbs2b --disable-libcaca --disable-libcdio --disable-libcelt --disable-libcodec2 --enable-libdav1d --disable-libdavs2 --disable-libdc1394 --disable-debug --enable-htmlpages --disable-libdrm --enable-libfdk-aac --disable-libflite --enable-fontconfig --enable-libfreetype --enable-frei0r --disable-libfribidi --disable-gcrypt --disable-libglslang --disable-libgme --enable-gmp --enable-gnutls --enable-version3 --disable-libgsm --enable-iconv --disable-libilbc --disable-libjack --disable-libklvanc --disable-libkvazaar --disable-ladspa --enable-libmp3lame --enable-liblensfun --enable-libbluray --disable-librsvg --disable-librtmp --disable-libxml2 --disable-lto --disable-lv2 --disable-mbedtls --disable-libmfx --disable-libmodplug --disable-libmysofa --enable-nonfree --disable-openal --disable-opencl --enable-libopencv --disable-opengl --disable-libopenh264 --enable-libopenjpeg --disable-libopenmpt --disable-openssl --enable-optimizations --enable-libopus --disable-pocketsphinx --disable-libpulse --disable-librabbitmq --disable-librav1e --enable-runtime-cpudetect --disable-librubberband --disable-sdl2 --disable-libsmbclient --disable-libsnappy --disable-sndio --disable-libsoxr --disable-libspeex --disable-libsrt --disable-libssh --disable-libtensorflow --disable-libtesseract --enable-libtheora --disable-libtwolame --enable-libv4l2 --enable-vaapi --disable-vapoursynth --enable-vdpau --disable-libvidstab --disable-libvmaf --enable-libvorbis --disable-libvo-amrwbenc --enable-libvpx --disable-vulkan --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --disable-libxavs2 --disable-libxcb --enable-libxvid --disable-outdev=xv --disable-libzimg --disable-libzmq --disable-libzvbi
  libavutil      56. 36.100 / 56. 51.100
Failed to open device at index 0: /sys/bus/pci/devices/._pci0000:00/class
GetDeviceName: unable to open pci.ids file
GetDeviceName unable to load pci.ids file
[DEVICE]
DeviceIndex=0
DEVICEINFO:VendorId=4660
DEVICEINFO:DeviceId=4369
DEVICEINFO:SubsytemVendorId=6900
DEVICEINFO:SubsytemDeviceId=4352
DEVICEINFO:DevPath=/sys/bus/pci/devices/pci0000:00
DEVICEINFO:DrmRender=/dev/dri/render0
DEVICEINFO:IsEnabled=1
DEVICEINFO:IsBootVga=1
DEVICEINFO:ApiVersionMajor=1
DEVICEINFO:ApiVersionMinor=9
DEVICEINFO:Driver=Intel i965 driver for Intel(R) Haswell - 2.4.1
[DECODER]
CodecName=MPEG2VIDEO
CodecProfile=MPEG2_SIMPLE
CodecId=2
MaxWidth=4096
MaxHeight=4096
ColorFormats=NV12
RTFormat=1
DecSliceMode=1
[/DECODER]
[DECODER]
CodecName=MPEG2VIDEO
CodecProfile=MPEG2_MAIN
CodecId=2
MaxWidth=4096
MaxHeight=4096
ColorFormats=NV12
RTFormat=1
DecSliceMode=1
[/DECODER]
[DECODER]
CodecName=H264
CodecProfile=H264_CONSTRAINED_BASELINE
CodecId=27
MaxWidth=4096
MaxHeight=4096
ColorFormats=NV12
RTFormat=17
DecSliceMode=1
[/DECODER]
[DECODER]
CodecName=H264
CodecProfile=H264_MAIN
CodecId=27
MaxWidth=4096
MaxHeight=4096
ColorFormats=NV12
RTFormat=17
DecSliceMode=1
[/DECODER]
[DECODER]
CodecName=H264
CodecProfile=H264_HIGH
CodecId=27
MaxWidth=4096
MaxHeight=4096
ColorFormats=NV12
RTFormat=17
DecSliceMode=1
[/DECODER]
[DECODER]
CodecName=WMV3
CodecProfile=VC1_SIMPLE
CodecId=71
MaxWidth=4096
MaxHeight=4096
ColorFormats=NV12
RTFormat=1
DecSliceMode=1
[/DECODER]
[DECODER]
CodecName=VC1
CodecProfile=VC1_SIMPLE
CodecId=70
MaxWidth=4096
MaxHeight=4096
ColorFormats=NV12
RTFormat=1
DecSliceMode=1
[/DECODER]
[DECODER]
CodecName=WMV3
CodecProfile=VC1_MAIN
CodecId=71
MaxWidth=4096
MaxHeight=4096
ColorFormats=NV12
RTFormat=1
DecSliceMode=1
[/DECODER]
[DECODER]
CodecName=VC1
CodecProfile=VC1_MAIN
CodecId=70
MaxWidth=4096
MaxHeight=4096
ColorFormats=NV12
RTFormat=1
DecSliceMode=1
[/DECODER]
[DECODER]
CodecName=WMV3
CodecProfile=VC1_COMPLEX
CodecId=71
MaxWidth=4096
MaxHeight=4096
ColorFormats=NV12
RTFormat=1
DecSliceMode=1
[/DECODER]
[DECODER]
CodecName=WMV3
CodecProfile=VC1_ADVANCED
CodecId=71
MaxWidth=4096
MaxHeight=4096
ColorFormats=NV12
RTFormat=1
DecSliceMode=1
[/DECODER]
[DECODER]
CodecName=VC1
CodecProfile=VC1_COMPLEX
CodecId=70
MaxWidth=4096
MaxHeight=4096
ColorFormats=NV12
RTFormat=1
DecSliceMode=1
[/DECODER]
[DECODER]
CodecName=VC1
CodecProfile=VC1_ADVANCED
CodecId=70
MaxWidth=4096
MaxHeight=4096
ColorFormats=NV12
RTFormat=1
DecSliceMode=1
[/DECODER]
[DECODER]
CodecName=MJPEG
CodecProfile=MJPEG_HUFFMAN_BASELINE_DCT
CodecId=7
MaxWidth=4096
MaxHeight=4096
ColorFormats=GRAY8 YUV411P YUV422P YUV440P YUV444P
RTFormat=31
DecSliceMode=1
[/DECODER]
[/DEVICE]

So success? I will pursue fixing the internal jail syslink as it does seem like that is needed. I can live without proper naming in the GUI as I don't exactly have any alternative option to differentiate between.

This concludes my available TS time today. I'll take a crack tomorrow at making this more smooth. The only change I did was to the postinit call by removing the ending ; image.thumb.png.0533081deef20e3d9d220e5889306e11.png and rebooting the server and the emby service in the jail. I'm confused as to why this would cause it to start working? 

I've attached the hardware_detection log and a ffmpeg-transcode log to show the decoding is functional?

ffmpeg-transcode-fd60f253-6136-480d-8fd1-7e82ead0eb0e_1.txt hardware_detection-63741685871.txt

 

 

Edited by Baenwort
Link to comment
Share on other sites

  • 2 weeks later...

Hi guys.

I'm really interested  to being able to use the Hardware acceleration. I tried what it was explained in this post but was not able to have the hardware transcoding status in the main dashboard screen. I also keeping having the h.264 SOFTWARE encoding label.

I'm pretty sure you guys will be able to manage that to allow us to use our hardware the most efficiently. It will be a real plus to having this feature working with emby. Since this is now working with Plex, I don't see any reasons why it should not work with Emby :)

I too have tested the plugin VS jail installation and I was able to get the VAAPI encoder only in the plugin. I would say that the main difference between both is there is couple of packages installed in the plugin that are not in the jails (like FFMPEG that is currently an installed package in the plugin version). I'll continue to follow up this thread and looking forward to get have a working solution for that.

Thanks

 

EDIT:

Don't really know why, but I got it working. The hardware detection works now and I can see all encoders/decoders options in emby transcoding/advanced.

Althought, even if all is correctly detected, I currently have a hanging problem. When I try to start a video, the GPU hang and I cannot play video.

Edited by eraser8
Link to comment
Share on other sites

If you are familiar with patching and hacking FreeBSD, you can get it to work, but If you're like me with zero linux knowledge, forget it. I won't bother until I can install Emby in a jail and hardware acceleration just works. Right now it doesn't. I use TrueNAS with FreeBSD 12.0 for backups and it would be nice to have Emby in there. Maybe some day FreeBSD will have what Emby needs built -in.

Link to comment
Share on other sites

On 08/12/2020 at 12:10, dcol said:

If you are familiar with patching and hacking FreeBSD, you can get it to work, but If you're like me with zero linux knowledge, forget it. I won't bother until I can install Emby in a jail and hardware acceleration just works. Right now it doesn't. I use TrueNAS with FreeBSD 12.0 for backups and it would be nice to have Emby in there. Maybe some day FreeBSD will have what Emby needs built -in.

I'm taking a bit of a different approach. This method feels too "hacky" to me, and kind of like a temporary solution. But I'm not sure what I'm doing will be considered any less "hacky" LOL

I created a backup of my TrueNAS server, shut it down and removed my boot disk (so I wouldn't accidentally screw it up). I then installed proxmox onto a new boot disk and started it up. In proxmox, I used the TrueNAS ISO to create a VM, passed through my HBA for the storage drives, logged into TrueNAS and restored the backup I had just created. Call me incredibly shocked when all of my jails just started back up and just worked as if I had never touched anything. I had read that it would be that easy, but I'm always skeptical that things like that will go smoothly.

From there, in proxmox I spun up an ubuntu LXC, mounted my TrueNAS NFS share, and installed Emby. I reloaded my Emby backup and let my library scan in.

So that's where I sit right now. I have Emby running on Linux alongside of TrueNAS on the same machine. I don't actually own a video card yet (I'm about to start shopping for one), but all I should have to do when I install it is pass it through to the LXC container that Emby is running in, make sure it has the drivers for the card installed, and I should be golden.

Link to comment
Share on other sites

  • 4 weeks later...

I have followed every direction mentioned here but without success. I'd appreciate if anyone can help me to figure out why.

The emby server is installed as plugin in Truenas (12.0-U1). The CPU is i5-4690K, which has integrated Graphics 4600. Both drm and dri are exposed to emby jail. I downloaded "sys.xz" provided by Duffyx and decompressed it in root directory.

My first problem is that the symlink of render0 to card0 does not get created by the post init script:

symlink.thumb.jpg.007c70ac6ba6d50affe806790f96823d.jpg

After emby is running, I manually executed the same commands and the symlink will be created successfully:

dev_dri.thumb.jpg.a41f64a9471104493ee0718e42a42a1d.jpg

The 2nd symlink has been created in "sys.xz" provided by Duffyx:

image.thumb.png.e7e4cebcc05593ea1382ba45d4d4d043.png

 

For some reason, the hardware was not detected:

 

transcoding.thumb.jpg.1dbcf9b677438cbc79dd794c113382fe.jpg

 

Here is the output from "vainfo":

root@emby:/usr/local/lib/emby-server/bin # vainfo
error: XDG_RUNTIME_DIR not set in the environment.
error: can't connect to X server!
libva info: VA-API version 1.10.0
libva info: Trying to open /usr/local/lib/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_10
libva error: /usr/local/lib/dri/iHD_drv_video.so init failed
libva info: va_openDriver() returns 1
libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_10
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.10 (libva 2.10.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Haswell Desktop - 2.4.1
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264MultiviewHigh      : VAEntrypointVLD
      VAProfileH264MultiviewHigh      : VAEntrypointEncSlice
      VAProfileH264StereoHigh         : VAEntrypointVLD
      VAProfileH264StereoHigh         : VAEntrypointEncSlice
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileJPEGBaseline           : VAEntrypointVLD
 

Here is the output when accessing the node and use it with the ffmpeg:

image.thumb.png.9b19cfaa59a52cf58c8cf49a3f230fc2.png

 

Link to comment
Share on other sites

Never mind. I got it working. As I mentioned previously, the symlink of render0 to card0 does not get created by the post init script. I moved these commands into jail's exec_poststart as Duffyx did. It did the trick. Now, the transcoding page of emby is showing the hardware options for both encoders and decoders. However, I don't know why H.265 option is not shown. Also, I encoded a sample video file with and without hardware option but find out there is no difference on performance. I wonder what I missed.

 

With hardware option, the encoding time is 34.76s (17.26 fps):

root@emby:/tmp # su -m emby -c "/usr/local/lib/emby-server/bin/ffmpeg -vaapi_device /dev/dri/renderD128 -i 00138.MTS -c:v libx265 -an -x265-params crf=25 test_hw.mp4"
ffmpeg version 4.3.0-emby_2020_05_23 Copyright (c) 2000-2019 the FFmpeg developers and softworkz for Emby LLC
  built with FreeBSD clang version 8.0.1 (tags/RELEASE_801/final 366581) (based on LLVM 8.0.1)
Execution Date: 2021-01-05 10:23:35
[AVHWDeviceContext @ 0x805932200] libva: /usr/local/lib/dri/iHD_drv_video.so init failed
Input #0, mpegts, from '00138.MTS':
  Duration: 00:00:10.02, start: 0.568567, bitrate: 24389 kb/s
  Program 1
    Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], Level 42, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc, Start-Time 0.602s
    Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 256 kb/s, Start-Time 0.569s
    Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090), 1920x1080, Start-Time 0.569s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> hevc (libx265))
Press [q] to stop, [?] for help
x265 [info]: HEVC encoder version 0.0
x265 [info]: build info [FreeBSD][clang 8.0.1][64 bit] 8bit+10bit+12bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x265 [info]: Main profile, Level-4.1 (Main tier)
x265 [info]: Thread pool created using 4 threads
x265 [info]: Slices                              : 1
x265 [info]: frame threads / pool features       : 2 / wpp(17 rows)
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
x265 [info]: ME / range / subpel / merge         : hex / 57 / 2 / 3
x265 [info]: Keyframe min / max / scenecut / bias  : 25 / 250 / 40 / 5.00
x265 [info]: Lookahead / bframes / badapt        : 20 / 4 / 2
x265 [info]: b-pyramid / weightp / weightb       : 1 / 1 / 0
x265 [info]: References / ref-limit  cu / depth  : 3 / off / on
x265 [info]: AQ: mode / str / qg-size / cu-tree  : 2 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress            : CRF-25.0 / 0.60
x265 [info]: tools: rd=3 psy-rd=2.00 early-skip rskip mode=1 signhide tmvp
x265 [info]: tools: b-intra strong-intra-smoothing lslices=6 deblock sao
Output #0, mp4, to 'test_hw.mp4':
  Metadata:
    encoder         : Lavf58.35.100
    Stream #0:0: Video: hevc (libx265) (hev1 / 0x31766568), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 59.94 fps, 60k tbn, 59.94 tbc
    Metadata:
      encoder         : Lavc58.62.100 libx265
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame=  600 fps= 17 q=-0.0 Lsize=    8569kB time=00:00:09.95 bitrate=7024.3kbits/s throttle=off speed=0.287x
video:8558kB audio:0kB subtitle:0kB other streams:0kB global headers:2kB muxing overhead: 0.122824%
    Last message repeated 1 times
EXIT
x265 [info]: frame I:      3, Avg QP:26.98  kb/s: 40753.65
x265 [info]: frame P:    151, Avg QP:28.21  kb/s: 17722.07
x265 [info]: frame B:    446, Avg QP:34.55  kb/s: 3145.68
x265 [info]: Weighted P-Frames: Y:14.6% UV:10.6%
x265 [info]: consecutive B-frames: 1.3% 0.6% 36.4% 30.5% 31.2%

encoded 600 frames in 34.76s (17.26 fps), 7002.11 kb/s, Avg QP:32.92

 

Without hardware option, the encoding time is 34.56s (17.36 fps):

root@emby:/tmp # su -m emby -c "/usr/local/lib/emby-server/bin/ffmpeg  -i 00138.MTS -c:v libx265 -an -x265-params crf=25 test_sw.mp4"
ffmpeg version 4.3.0-emby_2020_05_23 Copyright (c) 2000-2019 the FFmpeg developers and softworkz for Emby LLC
  built with FreeBSD clang version 8.0.1 (tags/RELEASE_801/final 366581) (based on LLVM 8.0.1)
Execution Date: 2021-01-05 10:20:53
Input #0, mpegts, from '00138.MTS':
  Duration: 00:00:10.02, start: 0.568567, bitrate: 24389 kb/s
  Program 1
    Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], Level 42, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc, Start-Time 0.602s
    Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 256 kb/s, Start-Time 0.569s
    Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090), 1920x1080, Start-Time 0.569s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> hevc (libx265))
Press [q] to stop, [?] for help
x265 [info]: HEVC encoder version 0.0
x265 [info]: build info [FreeBSD][clang 8.0.1][64 bit] 8bit+10bit+12bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x265 [info]: Main profile, Level-4.1 (Main tier)
x265 [info]: Thread pool created using 4 threads
x265 [info]: Slices                              : 1
x265 [info]: frame threads / pool features       : 2 / wpp(17 rows)
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
x265 [info]: ME / range / subpel / merge         : hex / 57 / 2 / 3
x265 [info]: Keyframe min / max / scenecut / bias  : 25 / 250 / 40 / 5.00
x265 [info]: Lookahead / bframes / badapt        : 20 / 4 / 2
x265 [info]: b-pyramid / weightp / weightb       : 1 / 1 / 0
x265 [info]: References / ref-limit  cu / depth  : 3 / off / on
x265 [info]: AQ: mode / str / qg-size / cu-tree  : 2 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress            : CRF-25.0 / 0.60
x265 [info]: tools: rd=3 psy-rd=2.00 early-skip rskip mode=1 signhide tmvp
x265 [info]: tools: b-intra strong-intra-smoothing lslices=6 deblock sao
Output #0, mp4, to 'test_sw.mp4':
  Metadata:
    encoder         : Lavf58.35.100
    Stream #0:0: Video: hevc (libx265) (hev1 / 0x31766568), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 59.94 fps, 60k tbn, 59.94 tbc
    Metadata:
      encoder         : Lavc58.62.100 libx265
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame=  600 fps= 17 q=-0.0 Lsize=    8569kB time=00:00:09.95 bitrate=7024.3kbits/s throttle=off speed=0.289x
video:8558kB audio:0kB subtitle:0kB other streams:0kB global headers:2kB muxing overhead: 0.122824%
    Last message repeated 1 times
EXIT
x265 [info]: frame I:      3, Avg QP:26.98  kb/s: 40753.65
x265 [info]: frame P:    151, Avg QP:28.21  kb/s: 17722.07
x265 [info]: frame B:    446, Avg QP:34.55  kb/s: 3145.68
x265 [info]: Weighted P-Frames: Y:14.6% UV:10.6%
x265 [info]: consecutive B-frames: 1.3% 0.6% 36.4% 30.5% 31.2%

encoded 600 frames in 34.56s (17.36 fps), 7002.11 kb/s, Avg QP:32.92


 

 

 

 

image.thumb.png.28f4cc8d009e37f47d35ff226fd9290c.png

image.png

Link to comment
Share on other sites

bingemeister

The output of vainfo you posted earlier today shows that your GPU doesn’t seem to support H.265. And later for both ffmpeg commands you used the option -c:v libx265 which is software encoding. You need to use -c:v hevc_vaapi to leverage hardware encoding for H.265/HEVC, but that of course won’t work if your GPU doesn’t support it.

Link to comment
Share on other sites

Thanks for pointing out my GPU does not support h.265. I revised the option to encode the video with h.264 (-c:v h264_vaapi). But the encoding failed. Did I do anything wrong?

root@emby:/tmp # su -m emby -c "/usr/local/lib/emby-server/bin/ffmpeg -vaapi_device /dev/dri/renderD128 -i 00138.MTS -c:v h264_vaapi test_hw.mp4"
ffmpeg version 4.3.0-emby_2020_05_23 Copyright (c) 2000-2019 the FFmpeg developers and softworkz for Emby LLC
  built with FreeBSD clang version 8.0.1 (tags/RELEASE_801/final 366581) (based on LLVM 8.0.1)
Execution Date: 2021-01-05 10:51:18
[AVHWDeviceContext @ 0x8059321c0] libva: /usr/local/lib/dri/iHD_drv_video.so init failed
Input #0, mpegts, from '00138.MTS':
  Duration: 00:00:10.02, start: 0.568567, bitrate: 24389 kb/s
  Program 1
    Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], Level 42, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc, Start-Time 0.602s
    Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 256 kb/s, Start-Time 0.569s
    Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090), 1920x1080, Start-Time 0.569s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_vaapi))
  Stream #0:1 -> #0:1 (ac3 (native) -> aac (native))
Press [q] to stop, [?] for help
Impossible to convert between the formats supported by the filter 'Parsed_null_0' and the filter 'auto_scaler_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Error while processing the decoded data for stream #0:0
[aac @ 0x80ac19400] Qavg: 134.983
[aac @ 0x80ac19400] 2 frames left in the queue on closing
Conversion failed!
 

Link to comment
Share on other sites

If Emby requires patching to get hardware decoding in FreeBSD to function, then I would like to see detailed instructions made for a zero FreeBSD knowledge person. Many people have TrueNAS which requires no knowledge of FreeBSD.

Link to comment
Share on other sites

  • 2 weeks later...

Hello,

 

I am trying to set up hw acceleration, but I have an issue with my graphic car / CPU

vgapci0@pci0:0:2:0:     class=0x030000 card=0x40491297 chip=0x19068086 rev=0x07 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'HD Graphics 510'
    class      = display
    subclass   = VGA

CPU: Intel(R) Celeron(R) CPU 3855U @ 1.60GHz (1608.07-MHz K8-class CPU)

FreeBSD-12.2

pkg :

drm-fbsd12.0-kmod-4.16.g20201016 DRM modules for the linuxkpi-based KMS components
drm-kmod-g20190710             Metaport of DRM modules for the linuxkpi-based KMS components

libva-intel-driver-2.4.1       VAAPI legacy driver for Intel GMA 4500 (Gen4) to UHD 630 (Gen9.5)
libva-intel-hybrid-driver-1.0.2_2 Hybrid VP8 encoder and VP9 decoder for Intel GPUs
libva-intel-media-driver-20.4.5 VAAPI driver for Intel HD 5000 (Gen8) or newer
xf86-video-intel-2.99.917.914,1 X.Org legacy driver for Intel integrated graphics chipsets

module are loaded :

 5    1 0xffffffff82978000   12ccb0 i915kms.ko
 6    1 0xffffffff82aa5000    76570 drm.ko

After a reboot, /dev/drm is created but not /dev/dri, I do not understand why :(

direct rendering: Yes
    GLX_MESA_multithread_makecurrent, GLX_MESA_query_renderer,
    GLX_EXT_visual_rating, GLX_MESA_copy_sub_buffer, GLX_MESA_query_renderer,
Extended renderer info (GLX_MESA_query_renderer):
OpenGL renderer string: llvmpipe (LLVM 10.0.1, 128 bits)
    GL_ARB_conditional_render_inverted, GL_ARB_conservative_depth,
    GL_NV_conditional_render, GL_NV_copy_image, GL_NV_depth_clamp,
    GL_ARB_conditional_render_inverted, GL_ARB_conservative_depth,
    GL_NV_conditional_render, GL_NV_copy_image, GL_NV_depth_clamp,
    GL_EXT_render_snorm, GL_EXT_robustness, GL_EXT_sRGB_write_control,
    GL_MESA_shader_integer_functions, GL_NV_conditional_render,
    GL_OES_element_index_uint, GL_OES_fbo_render_mipmap,

Do you have any idea ?

 

 

 

Link to comment
Share on other sites

ok found for this part, I had to compile driver and now it looks better :

[drm] Unable to create a private tmpfs mount, hugepage support will be disabled(-19).
[drm] Got stolen memory base 0x70000000, size 0x20000000
[drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[drm] Driver supports precise vblank timestamp query.
[drm] Connector HDMI-A-1: get mode from tunables:
[drm]   - kern.vt.fb.modes.HDMI-A-1
[drm]   - kern.vt.fb.default_mode
[drm] Connector DP-1: get mode from tunables:
[drm]   - kern.vt.fb.modes.DP-1
[drm]   - kern.vt.fb.default_mode
[drm] Connector HDMI-A-2: get mode from tunables:
[drm]   - kern.vt.fb.modes.HDMI-A-2
[drm]   - kern.vt.fb.default_mode
[drm] Initialized i915 1.6.0 20171222 for drmn0 on minor 0
name=drmn0 flags=0x0 stride=10240 bpp=32
drmn0: fb0: inteldrmfb frame buffer device
drmn0: fail (0) to get firmware image with name: i915/skl_dmc_ver1_27.bin
drmn0: successfully loaded firmware image with mapped name: i915_skl_dmc_ver1_27_bin
[drm] Finished loading DMC firmware i915/skl_dmc_ver1_27.bin (v1.27)

But in emby, I am not seing hardware in advanced.

Link to comment
Share on other sites

3 hours ago, Baenwort said:

Share for the next person to come along. :D

I missed to copy the sys archive ;)

I made some test after that (I bought a 1 month premiere subscription), it looks it's using hw acceleration.

But, in my case, most of my transcoding problem are from embedded subtitles, and hw do not help (or not so much).

But now, display on my server is better than 640x480, even if I am not using it :D

Just one bug, if I stop/start my jail, it won't find my emby devfs rules. I have to restart devfs service before starting emby jail.

 

Edited by gnubibi
Link to comment
Share on other sites

10 hours ago, gnubibi said:

I missed to copy the sys archive ;)

I made some test after that (I bought a 1 month premiere subscription), it looks it's using hw acceleration.

But, in my case, most of my transcoding problem are from embedded subtitles, and hw do not help (or not so much).

But now, display on my server is better than 640x480, even if I am not using it :D

Just one bug, if I stop/start my jail, it won't find my emby devfs rules. I have to restart devfs service before starting emby jail.

 

Hi, I'm passing on your findings to our other developers. Thanks !

Link to comment
Share on other sites

20 hours ago, gnubibi said:

I missed to copy the sys archive ;)

I made some test after that (I bought a 1 month premiere subscription), it looks it's using hw acceleration.

But, in my case, most of my transcoding problem are from embedded subtitles, and hw do not help (or not so much).

But now, display on my server is better than 640x480, even if I am not using it :D

Just one bug, if I stop/start my jail, it won't find my emby devfs rules. I have to restart devfs service before starting emby jail.

 

The fix I found for the devfs problem was posted in: 

basically there is something different between how FreeBSD and FreeNAS handle devfs.rules for jails that requires this work around. You can find others using the same thing on the TrueNAS forums but I haven't dug in to find a bug report or 'working as intended' reasoning. 

Link to comment
Share on other sites

thanks, I had this for the jail and it's doing the job :

exec_poststop:/usr/sbin/service devfs restart
exec_prestart:/usr/sbin/service devfs restart

it's dirty but it works :D

Edited by gnubibi
  • Like 1
Link to comment
Share on other sites

Once again, let us all know when it just works without all the 'hacks'. A nice clean patch would be acceptable.

Link to comment
Share on other sites

  • 1 month later...

My hacking is still working and has preserved across over 20 beta server updates without breaking or needing action on my part.

 

We will need someone who knows a heck of a lot more about scripting and the jail creation process to ever make a "patch" that doesn't require some server admin action.  Passing the GPU into the jail isn't something that has a easy check box that I know and that is the hardest part. Following that is knowing the correct drivers to get into the jail.  Maybe once the port away from mono is completed by the FreeBSD dev that Emby uses they might have time to work on this. 

So it is going to be years unless the community pitches in to help.

Edited by Baenwort
  • Thanks 1
Link to comment
Share on other sites

6 hours ago, Baenwort said:

My hacking is still working and has preserved across over 20 beta server updates without breaking or needing action on my part.

 

We will need someone who knows a heck of a lot more about scripting and the jail creation process to ever make a "patch" that doesn't require some server admin action.  Passing the GPU into the jail isn't something that has a easy check box that I know and that is the hardest part. Following that is knowing the correct drivers to get into the jail.  Maybe once the port away from mono is completed by the FreeBSD dev that Emby uses they might have time to work on this. 

So it is going to be years unless the community pitches in to help.

It's good to hear that updates aren't breaking the work you did to get the GPU to pass into the jail, that would be my first concern. Have you noticed any inconsistencies with transcoding thus far?

Link to comment
Share on other sites

On 3/14/2021 at 4:49 PM, Bottomnotc said:

It's good to hear that updates aren't breaking the work you did to get the GPU to pass into the jail, that would be my first concern. Have you noticed any inconsistencies with transcoding thus far?

Not yet but I'm not exhaustively testing it and there are never more than 2 users at a time. 

There are some formats that don't use it due to the age of the i3-4130 CPU that powers my TrueNAS system. 

Link to comment
Share on other sites

  • 4 months later...

Any chance someone would show performance + specs of the hardware used..? 

I want to use TrueNAS + a 1080 Ti or perhaps 2080 ... etc., something that's not outrageously expensive to create proxies for Premiere Pro (macOS) ... 

If you need CODEC info, LMK and I'll provide that info. 

Also, if using a GPU for transcoding do I still want to use a CPU which has QS (Quick Sync) ..? 
How powerful of a CPU makes sense ..? My goal is to get transcoding performance which is both superior to my MP6,1 ... while also offloading the demand of the GPUs as they become increasingly expensive ... both of which should be EASILY done with a Coffee Lake i7 + (for consumer procs) or a high clock-speed Xeon (as is also best for SMB if I'm not mistaken). 

PS, just as a MANTRA!! Please remember to NEVER ENABLE DEDUPLICATION WILLY-NILLY ... as it will CRIPPLE your TrueNAS or FreeNAS machine without using exorbitantly expensive hardware ... and anyone you know who's struggling with a sloooow FN etc., that performs FAR below what their hardware / Network should ...? Should also check if they've enabled DeDuplication!! Thanks! 

Link to comment
Share on other sites

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...