jellyfin / jellyfin

The Free Software Media System
https://jellyfin.org
GNU General Public License v2.0
35.5k stars 3.22k forks source link

Add nvdec/nvenc support to Docker image #482

Closed BobOkisama closed 5 years ago

BobOkisama commented 5 years ago

Was chatting with guys on a reddit thread about this, here is what we have tried thus far: Added -v /dev/dri/renderD128:/dev/dri/renderD128 \ to my container Chmod 777 /dev/dri/renderD128 Downloaded Van's 4.1 latest and mapped that to the container Pointed JF to the static 4.1 and tried to use that direct

Basically what it is doing is just going directly to software transcoding and does not even looks like it attempts nvenc/dec. I have also tried multiple files, just forcing 720p 3 meg to make it transcode atm. Also worth noting that HW transcoding is working on my plex load on this same box and my card is the Quadro P2000 with 390.59 drivers.

Logs (click to expand) ``` {"Protocol":"File","Id":"4792459ea92c04bb4f8bd731d4e29c21","Path":"/media/boboki/Media/BobOki/4K/Arrival.2016.2160p.Remux.UHD.BluRay.HDR.DTS-HD.MA7.1.x265-UHDCL.mp4","Type":"Default","Container":"mov,mp4,m4a,3gp,3g2,mj2","Name":"Arrival.2016.2160p.Remux.UHD.BluRay.HDR.DTS-HD.MA7.1.x265-UHDCL","IsRemote":false,"ETag":"31bffc11008697604b578bf151298851","RunTimeTicks":69822717952,"ReadAtNativeFramerate":false,"IgnoreDts":false,"IgnoreIndex":false,"GenPtsInput":false,"SupportsTranscoding":true,"SupportsDirectStream":true,"SupportsDirectPlay":true,"IsInfiniteStream":false,"RequiresOpening":false,"RequiresClosing":false,"RequiresLooping":false,"SupportsProbing":true,"VideoType":"VideoFile","MediaStreams":[{"Codec":"hevc","CodecTag":"hev1","Language":"eng","TimeBase":"1/16000","CodecTimeBase":"125/2997","VideoRange":"SDR","DisplayTitle":"4K HEVC","IsInterlaced":false,"BitRate":21114367,"RefFrames":1,"IsDefault":true,"IsForced":false,"Height":1608,"Width":3840,"AverageFrameRate":23.9760017,"RealFrameRate":23.9760246,"Profile":"Main 10","Type":"Video","AspectRatio":"2.40:1","Index":0,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"PixelFormat":"yuv420p10le","Level":150},{"Codec":"dts","CodecTag":"mp4a","Language":"eng","TimeBase":"1/48000","CodecTimeBase":"1/48000","DisplayTitle":"Eng DTS 7.1 Default","IsInterlaced":false,"ChannelLayout":"7.1","BitDepth":24,"Channels":8,"SampleRate":48000,"IsDefault":true,"IsForced":false,"Profile":"DTS-HD MA","Type":"Audio","Index":1,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Level":0},{"Codec":"srt","Language":"ger","DisplayTitle":"Ger","IsInterlaced":false,"IsDefault":false,"IsForced":false,"Type":"Subtitle","Index":2,"IsExternal":true,"IsTextSubtitleStream":true,"SupportsExternalStream":true,"Path":"/media/boboki/Media/BobOki/4K/Arrival.2016.2160p.Remux.UHD.BluRay.HDR.DTS-HD.MA7.1.x265-UHDCL.de.srt"},{"Codec":"srt","Language":"eng","DisplayTitle":"Eng","IsInterlaced":false,"IsDefault":false,"IsForced":false,"Type":"Subtitle","Index":3,"IsExternal":true,"IsTextSubtitleStream":true,"SupportsExternalStream":true,"Path":"/media/boboki/Media/BobOki/4K/Arrival.2016.2160p.Remux.UHD.BluRay.HDR.DTS-HD.MA7.1.x265-UHDCL.en.srt"},{"Codec":"srt","Language":"spa","DisplayTitle":"Spa","IsInterlaced":false,"IsDefault":false,"IsForced":false,"Type":"Subtitle","Index":4,"IsExternal":true,"IsTextSubtitleStream":true,"SupportsExternalStream":true,"Path":"/media/boboki/Media/BobOki/4K/Arrival.2016.2160p.Remux.UHD.BluRay.HDR.DTS-HD.MA7.1.x265-UHDCL.es.srt"}],"Formats":[],"Bitrate":25332586,"RequiredHttpHeaders":{}} /opt/ffmpeg/ffmpeg-4.1-64bit-static/ffmpeg -i file:"/media/boboki/Media/BobOki/4K/Arrival.2016.2160p.Remux.UHD.BluRay.HDR.DTS-HD.MA7.1.x265-UHDCL.mp4" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 libx264 -pix_fmt yuv420p -preset veryfast -crf 21 -maxrate 2616000 -bufsize 5232000 -profile:v high -level 4.1 -x264opts:0 subme=0:me_range=4:rc_lookahead=10:me=dia:no_chroma_me:8x8dct=0:partitions=none -force_key_frames "expr:gte(t,n_forced*3)" -vf "scale=trunc(min(max(iw\,ih*dar)\,1280)/2)*2:trunc(ow/dar/2)*2" -copyts -vsync -1 -codec:a:0 libmp3lame -ac 2 -ab 384000 -af "volume=2" -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3 -individual_header_trailer 0 -segment_format mpegts -segment_list_type m3u8 -segment_start_number 0 -segment_list "/tmp/transcoding-temp/593adbf39edffecacee6e1d207fa208c.m3u8" -y "/tmp/transcoding-temp/593adbf39edffecacee6e1d207fa208c%d.ts" ffmpeg version 4.1-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2018 the FFmpeg developers built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516 configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg libavutil 56. 22.100 / 56. 22.100 libavcodec 58. 35.100 / 58. 35.100 libavformat 58. 20.100 / 58. 20.100 libavdevice 58. 5.100 / 58. 5.100 libavfilter 7. 40.101 / 7. 40.101 libswscale 5. 3.100 / 5. 3.100 libswresample 3. 3.100 / 3. 3.100 libpostproc 55. 3.100 / 55. 3.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file:/media/boboki/Media/BobOki/4K/Arrival.2016.2160p.Remux.UHD.BluRay.HDR.DTS-HD.MA7.1.x265-UHDCL.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2mp41 creation_time : 2017-04-14T17:46:00.000000Z title : Arrival (2016) - Release for ULTRAHDCLUB encoder : Lavf58.2.103 Duration: 01:56:22.27, start: 0.000000, bitrate: 25332 kb/s Chapter #0:0: start 0.000000, end 589.213000 Metadata: title : 00:00:00.000 Chapter #0:1: start 589.213000, end 1052.842000 Metadata: title : 00:09:49.213 Chapter #0:2: start 1052.842000, end 1407.571000 Metadata: title : 00:17:32.842 Chapter #0:3: start 1407.571000, end 2033.447000 Metadata: title : 00:23:27.571 Chapter #0:4: start 2033.447000, end 2460.999000 Metadata: title : 00:33:53.447 Chapter #0:5: start 2460.999000, end 3145.392000 Metadata: title : 00:41:00.999 Chapter #0:6: start 3145.392000, end 3453.867000 Metadata: title : 00:52:25.392 Chapter #0:7: start 3453.867000, end 3785.740000 Metadata: title : 00:57:33.867 Chapter #0:8: start 3785.740000, end 4168.497000 Metadata: title : 01:03:05.740 Chapter #0:9: start 4168.497000, end 4568.689000 Metadata: title : 01:09:28.497 Chapter #0:10: start 4568.689000, end 5121.115000 Metadata: title : 01:16:08.689 Chapter #0:11: start 5121.115000, end 5736.355000 Metadata: title : 01:25:21.115 Chapter #0:12: start 5736.355000, end 6325.985000 Metadata: title : 01:35:36.355 Chapter #0:13: start 6325.985000, end 6982.272000 Metadata: title : 01:45:25.985 Stream #0:0(eng): Video: hevc (Main 10) (hev1 / 0x31766568), yuv420p10le(tv, bt2020nc/bt2020/smpte2084), 3840x1608, 21114 kb/s, SAR 1:1 DAR 160:67, 23.98 fps, 23.98 tbr, 16k tbn, 23.98 tbc (default) Metadata: creation_time : 2017-04-14T17:46:00.000000Z handler_name : VideoHandler Stream #0:1(eng): Audio: dts (DTS-HD MA) (mp4a / 0x6134706D), 48000 Hz, 7.1, s32p (24 bit) (default) Metadata: creation_time : 2017-04-14T17:46:00.000000Z handler_name : SoundHandler Stream #0:2(eng): Data: bin_data (text / 0x74786574) Metadata: creation_time : 2017-04-14T17:46:00.000000Z handler_name : SubtitleHandler Stream mapping: Stream #0:0 -> #0:0 (hevc (native) -> h264 (libx264)) Stream #0:1 -> #0:1 (dts (dca) -> mp3 (libmp3lame)) Press [q] to stop, [?] for help [libx264 @ 0x6bf2b00] using SAR=1/1 [libx264 @ 0x6bf2b00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX [libx264 @ 0x6bf2b00] profile Main, level 4.1, 4:2:0, 8-bit [libx264 @ 0x6bf2b00] 264 - core 157 r2935 545de2f - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x1:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=4 chroma_me=0 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=17 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=1 keyint=250 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=10 rc=crf mbtree=1 crf=21.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=2616 vbv_bufsize=5232 crf_max=0.0 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00 [segment @ 0x6bf1600] Opening '/tmp/transcoding-temp/593adbf39edffecacee6e1d207fa208c0.ts' for writing Output #0, segment, to '/tmp/transcoding-temp/593adbf39edffecacee6e1d207fa208c%d.ts': Metadata: encoder : Lavf58.20.100 Stream #0:0: Video: h264 (libx264), yuv420p, 1280x536 [SAR 1:1 DAR 160:67], q=-1--1, 23.98 fps, 90k tbn, 23.98 tbc (default) Metadata: encoder : Lavc58.35.100 libx264 Side data: cpb: bitrate max/min/avg: 2616000/0/0 buffer size: 5232000 vbv_delay: -1 Stream #0:1: Audio: mp3 (libmp3lame), 48000 Hz, stereo, fltp (24 bit), 384 kb/s (default) Metadata: encoder : Lavc58.35.100 libmp3lame frame= 18 fps=0.0 q=0.0 size=N/A time=00:00:01.27 bitrate=N/A speed=2.52x frame= 54 fps= 54 q=26.0 size=N/A time=00:00:02.76 bitrate=N/A speed=2.74x frame= 90 fps= 60 q=26.0 size=N/A time=00:00:04.27 bitrate=N/A speed=2.83x [segment @ 0x6bf1600] Opening '/tmp/transcoding-temp/593adbf39edffecacee6e1d207fa208c.m3u8.tmp' for writing [segment @ 0x6bf1600] Opening '/tmp/transcoding-temp/593adbf39edffecacee6e1d207fa208c1.ts' for writing frame= 127 fps= 63 q=26.0 size=N/A time=00:00:05.80 bitrate=N/A speed=2.88x frame= 163 fps= 65 q=26.0 size=N/A time=00:00:07.31 bitrate=N/A speed= 2.9x [segment @ 0x6bf1600] Opening '/tmp/transcoding-temp/593adbf39edffecacee6e1d207fa208c.m3u8.tmp' for writing [segment @ 0x6bf1600] Opening '/tmp/transcoding-temp/593adbf39edffecacee6e1d207fa208c2.ts' for writing frame= 198 fps= 65 q=26.0 size=N/A time=00:00:08.78 bitrate=N/A speed=2.91x frame= 234 fps= 66 q=26.0 size=N/A time=00:00:10.27 bitrate=N/A speed=2.91x [segment @ 0x6bf1600] Opening '/tmp/transcoding-temp/593adbf39edffecacee6e1d207fa208c.m3u8.tmp' for writing [segment @ 0x6bf1600] Opening '/tmp/transcoding-temp/593adbf39edffecacee6e1d207fa208c3.ts' for writing frame= 269 fps= 67 q=26.0 size=N/A time=00:00:11.73 bitrate=N/A speed=2.91x frame= 305 fps= 67 q=26.0 size=N/A time=00:00:13.27 bitrate=N/A speed=2.93x [segment @ 0x6bf1600] Opening '/tmp/transcoding-temp/593adbf39edffecacee6e1d207fa208c.m3u8.tmp' for writing [segment @ 0x6bf1600] Opening '/tmp/transcoding-temp/593adbf39edffecacee6e1d207fa208c4.ts' for writing frame= 342 fps= 68 q=26.0 size=N/A time=00:00:14.78 bitrate=N/A speed=2.93x frame= 379 fps= 68 q=26.0 size=N/A time=00:00:16.32 bitrate=N/A speed=2.94x [segment @ 0x6bf1600] Opening '/tmp/transcoding-temp/593adbf39edffecacee6e1d207fa208c.m3u8.tmp' for writing [segment @ 0x6bf1600] Opening '/tmp/transcoding-temp/593adbf39edffecacee6e1d207fa208c5.ts' for writing frame= 416 fps= 69 q=26.0 size=N/A time=00:00:17.87 bitrate=N/A speed=2.95x frame= 453 fps= 69 q=26.0 size=N/A time=00:00:19.41 bitrate=N/A speed=2.96x [segment @ 0x6bf1600] Opening '/tmp/transcoding-temp/593adbf39edffecacee6e1d207fa208c.m3u8.tmp' for writing [segment @ 0x6bf1600] Opening '/tmp/transcoding-temp/593adbf39edffecacee6e1d207fa208c6.ts' for writing frame= 490 fps= 69 q=26.0 size=N/A time=00:00:20.95 bitrate=N/A speed=2.97x frame= 526 fps= 70 q=26.0 size=N/A time=00:00:22.46 bitrate=N/A speed=2.97x [segment @ 0x6bf1600] Opening '/tmp/transcoding-temp/593adbf39edffecacee6e1d207fa208c.m3u8.tmp' for writing [segment @ 0x6bf1600] Opening '/tmp/transcoding-temp/593adbf39edffecacee6e1d207fa208c7.ts' for writing [segment @ 0x6bf1600] Opening '/tmp/transcoding-temp/593adbf39edffecacee6e1d207fa208c.m3u8.tmp' for writing frame= 557 fps= 69 q=-1.0 Lsize=N/A time=00:00:23.85 bitrate=N/A speed=2.97x video:3340kB audio:933kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown [libx264 @ 0x6bf2b00] frame I:10 Avg QP:14.90 size: 24519 [libx264 @ 0x6bf2b00] frame P:168 Avg QP:19.02 size: 10206 [libx264 @ 0x6bf2b00] frame B:379 Avg QP:20.67 size: 3851 [libx264 @ 0x6bf2b00] consecutive B-frames: 7.2% 3.6% 8.1% 81.1% ```
rhee876527 commented 5 years ago

Should be --device not volume map (-v). i.e --device /dev/dri/renderD128:/dev/dri/renderD128 \

Added -v /dev/dri/renderD128:/dev/dri/renderD128 \ to my container `

BobOkisama commented 5 years ago

I changed it to --device and tried both nvidia and vaapi with the same results. Nvidia just goes straight to software dec/enc and vaapi just sits and spins and never starts. I tried vaapi with both renderD128 and D129. I tried both /usr/bin/ffmpeg and the Van's static 4.1 sitting at /opt/ffmpeg/ffmpeg-4.1-64bit-static/ffmpeg on my system.

rhee876527 commented 5 years ago

Okay. @BobOkisama you are actually right. SInce V10 release, HW transcoding is not working for me either using static build from John. My test is from an Intel based server. I believe my issue is almost same expect ffmpeg exits for me. Doesn't even try software decode. Previous JF version had working HW transcode. I append my related logs here for further inquiry into why HW transcode fails with v10:

Logs (click to expand) ``` [17:34:19] [INF] HTTP Response 200 to ::1. Time: 16ms. http://localhost:8096/emby/System/Configuration/encoding [17:34:19] [INF] HTTP GET http://localhost:8096/emby/System/Info. UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36 [17:34:19] [INF] HTTP Response 200 to ::1. Time: 83ms. http://localhost:8096/emby/web/configurationpages?pageType=PluginConfiguration&EnableInMainMenu=true [17:34:19] [INF] HTTP GET http://localhost:8096/web/css/images/logoblack.png. UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36 [17:34:19] [INF] HTTP Response 304 to ::1. Time: 2ms. http://localhost:8096/web/css/images/logoblack.png [17:34:19] [INF] HTTP Response 200 to ::1. Time: 521ms. http://localhost:8096/emby/System/Info [17:34:24] [INF] HTTP GET http://localhost:8096/emby/System/Endpoint. UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36 [17:34:24] [INF] HTTP Response 200 to ::1. Time: 49ms. http://localhost:8096/emby/System/Endpoint [17:34:34] [INF] HTTP GET http://192.168.0.13:8096/emby/Users/50e1539e2e454b67bc4f8e36997bbcd7/Items/eb419be0721a19b4e2a096edcb5a368a?format=json. UserAgent: Dalvik/2.1.0 (Linux; U; Android 7.0; BRAVIA 4K GB Build/NRD91N.S139) [17:34:35] [INF] HTTP Response 200 to 192.168.0.15. Time: 593ms. http://192.168.0.13:8096/emby/Users/50e1539e2e454b67bc4f8e36997bbcd7/Items/eb419be0721a19b4e2a096edcb5a368a?format=json [17:34:35] [INF] WS http://192.168.0.13:8096/emby/embywebsocket?api_key=be595dc7fcdb44329b3b326ffb8444ec&deviceId=aee2029c13980366. UserAgent: [17:34:36] [INF] HTTP POST http://192.168.0.13:8096/emby/Items/eb419be0721a19b4e2a096edcb5a368a/PlaybackInfo?format=json. UserAgent: Dalvik/2.1.0 (Linux; U; Android 7.0; BRAVIA 4K GB Build/NRD91N.S139) [17:34:36] [INF] User policy for martin. EnablePlaybackRemuxing: True EnableVideoPlaybackTranscoding: True EnableAudioPlaybackTranscoding: True [17:34:36] [INF] Profile: Android-Exo, Path: /media/Movies/Summer '03 (2018)/Summer '03 (2018) [WEB-DL].mkv, isEligibleForDirectPlay: True, isEligibleForDirectStream: True [17:34:37] [INF] Profile: Android-Exo, Path: /media/Movies/Summer '03 (2018)/Summer '03 (2018) [WEB-DL].mkv, isEligibleForDirectPlay: True, isEligibleForDirectStream: True [17:34:37] [INF] Profile: Android-Exo, Path: /media/Movies/Summer '03 (2018)/Summer '03 (2018) [WEB-DL].mkv, isEligibleForDirectPlay: True, isEligibleForDirectStream: True [17:34:37] [INF] HTTP Response 200 to 192.168.0.15. Time: 410ms. http://192.168.0.13:8096/emby/Items/eb419be0721a19b4e2a096edcb5a368a/PlaybackInfo?format=json [17:34:37] [INF] HTTP POST http://192.168.0.13:8096/emby/Sessions/Playing. UserAgent: Dalvik/2.1.0 (Linux; U; Android 7.0; BRAVIA 4K GB Build/NRD91N.S139) [17:34:37] [INF] HTTP Response 204 to 192.168.0.15. Time: 240ms. http://192.168.0.13:8096/emby/Sessions/Playing [17:34:37] [INF] HTTP GET http://192.168.0.13:8096/emby/Videos/eb419be0721a19b4e2a096edcb5a368a/stream.mkv?DeviceId=aee2029c13980366&MediaSourceId=eb419be0721a19b4e2a096edcb5a368a&Static=true&Tag=139a6c69469c4c7035f0ab5765c3602e. User-Agent=Emby/1.6.15g (Linux;Android 7.0) ExoPlayerLib/2.8.1/Emby, Accept-Encoding=identity, Host=192.168.0.13:8096, Connection=Keep-Alive [17:34:37] [INF] HTTP GET http://192.168.0.13:8096/emby/Videos/eb419be0721a19b4e2a096edcb5a368a/stream.mkv?DeviceId=aee2029c13980366&MediaSourceId=eb419be0721a19b4e2a096edcb5a368a&Static=true&Tag=139a6c69469c4c7035f0ab5765c3602e. Range=bytes=3544300811-, User-Agent=Emby/1.6.15g (Linux;Android 7.0) ExoPlayerLib/2.8.1/Emby, Accept-Encoding=identity, Host=192.168.0.13:8096, Connection=Keep-Alive [17:34:37] [INF] Setting range response values for /media/Movies/Summer '03 (2018)/Summer '03 (2018) [WEB-DL].mkv. RangeRequest: bytes=3544300811- Content-Length: 37709, Content-Range: bytes 3544300811-3544338519/3544338520 [17:34:37] [INF] HTTP Response 206 to 192.168.0.15. Time: 45ms. http://192.168.0.13:8096/emby/Videos/eb419be0721a19b4e2a096edcb5a368a/stream.mkv?DeviceId=aee2029c13980366&MediaSourceId=eb419be0721a19b4e2a096edcb5a368a&Static=true&Tag=139a6c69469c4c7035f0ab5765c3602e [17:34:37] [ERR] Error this.ProcessRequest(context)(Exception while writing error to the response) System.InvalidOperationException: Operation is not valid due to the current state of the object. at SocketHttpListener.Net.HttpListenerResponse.set_ContentLength64(Int64 value) in /repo/SocketHttpListener/Net/HttpListenerResponse.cs:line 99 at Emby.Server.Implementations.HttpServer.HttpListenerHost.Write(IResponse response, String text) in /repo/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs:line 735 at Emby.Server.Implementations.HttpServer.HttpListenerHost.ErrorHandler(Exception ex, IRequest httpReq, Boolean logExceptionStackTrace, Boolean logExceptionMessage) in /repo/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs:line 266  [17:34:37] [INF] HTTP Response 500 to 192.168.0.15. Time: 407ms. http://192.168.0.13:8096/emby/Videos/eb419be0721a19b4e2a096edcb5a368a/stream.mkv?DeviceId=aee2029c13980366&MediaSourceId=eb419be0721a19b4e2a096edcb5a368a&Static=true&Tag=139a6c69469c4c7035f0ab5765c3602e [17:34:37] [INF] HTTP GET http://192.168.0.13:8096/emby/Videos/eb419be0721a19b4e2a096edcb5a368a/stream.mkv?DeviceId=aee2029c13980366&MediaSourceId=eb419be0721a19b4e2a096edcb5a368a&Static=true&Tag=139a6c69469c4c7035f0ab5765c3602e. Range=bytes=68424-, User-Agent=Emby/1.6.15g (Linux;Android 7.0) ExoPlayerLib/2.8.1/Emby, Accept-Encoding=identity, Host=192.168.0.13:8096, Connection=Keep-Alive [17:34:37] [INF] Setting range response values for /media/Movies/Summer '03 (2018)/Summer '03 (2018) [WEB-DL].mkv. RangeRequest: bytes=68424- Content-Length: 3544270096, Content-Range: bytes 68424-3544338519/3544338520 [17:34:38] [ERR] Error this.ProcessRequest(context)(Exception while writing error to the response) System.InvalidOperationException: Operation is not valid due to the current state of the object. at SocketHttpListener.Net.HttpListenerResponse.set_ContentLength64(Int64 value) in /repo/SocketHttpListener/Net/HttpListenerResponse.cs:line 99 at Emby.Server.Implementations.HttpServer.HttpListenerHost.Write(IResponse response, String text) in /repo/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs:line 735 at Emby.Server.Implementations.HttpServer.HttpListenerHost.ErrorHandler(Exception ex, IRequest httpReq, Boolean logExceptionStackTrace, Boolean logExceptionMessage) in /repo/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs:line 266  [17:34:38] [INF] HTTP Response 500 to 192.168.0.15. Time: 635ms. http://192.168.0.13:8096/emby/Videos/eb419be0721a19b4e2a096edcb5a368a/stream.mkv?DeviceId=aee2029c13980366&MediaSourceId=eb419be0721a19b4e2a096edcb5a368a&Static=true&Tag=139a6c69469c4c7035f0ab5765c3602e [17:34:38] [INF] HTTP GET http://192.168.0.13:8096/emby/Videos/eb419be0721a19b4e2a096edcb5a368a/stream.mkv?DeviceId=aee2029c13980366&MediaSourceId=eb419be0721a19b4e2a096edcb5a368a&Static=true&Tag=139a6c69469c4c7035f0ab5765c3602e. Range=bytes=553448067-, User-Agent=Emby/1.6.15g (Linux;Android 7.0) ExoPlayerLib/2.8.1/Emby, Accept-Encoding=identity, Host=192.168.0.13:8096, Connection=Keep-Alive [17:34:38] [INF] Setting range response values for /media/Movies/Summer '03 (2018)/Summer '03 (2018) [WEB-DL].mkv. RangeRequest: bytes=553448067- Content-Length: 2990890453, Content-Range: bytes 553448067-3544338519/3544338520 [17:34:39] [INF] HTTP POST http://192.168.0.13:8096/emby/Sessions/Playing/Progress. UserAgent: Dalvik/2.1.0 (Linux; U; Android 7.0; BRAVIA 4K GB Build/NRD91N.S139) [17:34:39] [INF] HTTP Response 204 to 192.168.0.15. Time: 32ms. http://192.168.0.13:8096/emby/Sessions/Playing/Progress [17:34:42] [INF] HTTP POST http://192.168.0.13:8096/emby/Sessions/Playing/Progress. UserAgent: Dalvik/2.1.0 (Linux; U; Android 7.0; BRAVIA 4K GB Build/NRD91N.S139) [17:34:42] [INF] HTTP Response 204 to 192.168.0.15. Time: 5ms. http://192.168.0.13:8096/emby/Sessions/Playing/Progress [17:34:49] [INF] HTTP POST http://192.168.0.13:8096/emby/Items/eb419be0721a19b4e2a096edcb5a368a/PlaybackInfo?format=json. UserAgent: Dalvik/2.1.0 (Linux; U; Android 7.0; BRAVIA 4K GB Build/NRD91N.S139) [17:34:49] [INF] User policy for martin. EnablePlaybackRemuxing: True EnableVideoPlaybackTranscoding: True EnableAudioPlaybackTranscoding: True [17:34:49] [INF] Bitrate exceeds DirectStream limit: media bitrate: 5346891, max bitrate: 3000000 [17:34:49] [INF] Profile: Android-Exo, Path: /media/Movies/Summer '03 (2018)/Summer '03 (2018) [WEB-DL].mkv, isEligibleForDirectPlay: True, isEligibleForDirectStream: False [17:34:49] [INF] Bitrate exceeds DirectStream limit: media bitrate: 5346891, max bitrate: 3000000 [17:34:49] [INF] Profile: Android-Exo, Path: /media/Movies/Summer '03 (2018)/Summer '03 (2018) [WEB-DL].mkv, isEligibleForDirectPlay: True, isEligibleForDirectStream: False [17:34:49] [INF] Bitrate exceeds DirectStream limit: media bitrate: 5346891, max bitrate: 3000000 [17:34:49] [INF] Profile: Android-Exo, Path: /media/Movies/Summer '03 (2018)/Summer '03 (2018) [WEB-DL].mkv, isEligibleForDirectPlay: True, isEligibleForDirectStream: False [17:34:49] [INF] HTTP Response 200 to 192.168.0.15. Time: 158ms. http://192.168.0.13:8096/emby/Items/eb419be0721a19b4e2a096edcb5a368a/PlaybackInfo?format=json [17:34:50] [INF] HTTP POST http://192.168.0.13:8096/emby/Sessions/Playing. UserAgent: Dalvik/2.1.0 (Linux; U; Android 7.0; BRAVIA 4K GB Build/NRD91N.S139) [17:34:50] [INF] HTTP Response 204 to 192.168.0.15. Time: 21ms. http://192.168.0.13:8096/emby/Sessions/Playing [17:34:50] [INF] HTTP GET http://192.168.0.13:8096/emby/videos/eb419be0-721a-19b4-e2a0-96edcb5a368a/master.m3u8?DeviceId=aee2029c13980366&MediaSourceId=eb419be0721a19b4e2a096edcb5a368a&VideoCodec=h264,mpeg2video,hevc,h265&AudioCodec=ac3,eac3,aac,mp3&AudioStreamIndex=1&VideoBitrate=2616000&AudioBitrate=384000&PlaySessionId=b9453a6c27ca461d9a08719f1f7db1a9&CopyTimestamps=true&RequireAvc=false&Tag=139a6c69469c4c7035f0ab5765c3602e&SegmentContainer=ts&MinSegments=2&BreakOnNonKeyFrames=True&h264-profile=high,main,baseline,constrainedbaseline&h264-level=51&hevc-profile=Main,Main10&ac3-audiochannels=8&eac3-audiochannels=8&aac-audiochannels=8&mp3-audiochannels=8&TranscodeReasons=ContainerBitrateExceedsLimit. User-Agent=Emby/1.6.15g (Linux;Android 7.0) ExoPlayerLib/2.8.1/Emby, Host=192.168.0.13:8096, Connection=Keep-Alive, Accept-Encoding=gzip [17:34:50] [INF] HTTP Response 200 to 192.168.0.15. Time: 34ms. http://192.168.0.13:8096/emby/videos/eb419be0-721a-19b4-e2a0-96edcb5a368a/master.m3u8?DeviceId=aee2029c13980366&MediaSourceId=eb419be0721a19b4e2a096edcb5a368a&VideoCodec=h264,mpeg2video,hevc,h265&AudioCodec=ac3,eac3,aac,mp3&AudioStreamIndex=1&VideoBitrate=2616000&AudioBitrate=384000&PlaySessionId=b9453a6c27ca461d9a08719f1f7db1a9&CopyTimestamps=true&RequireAvc=false&Tag=139a6c69469c4c7035f0ab5765c3602e&SegmentContainer=ts&MinSegments=2&BreakOnNonKeyFrames=True&h264-profile=high,main,baseline,constrainedbaseline&h264-level=51&hevc-profile=Main,Main10&ac3-audiochannels=8&eac3-audiochannels=8&aac-audiochannels=8&mp3-audiochannels=8&TranscodeReasons=ContainerBitrateExceedsLimit [17:34:50] [INF] HTTP GET http://192.168.0.13:8096/emby/videos/eb419be0-721a-19b4-e2a0-96edcb5a368a/main.m3u8?DeviceId=aee2029c13980366&MediaSourceId=eb419be0721a19b4e2a096edcb5a368a&VideoCodec=h264,mpeg2video,hevc,h265&AudioCodec=ac3,eac3,aac,mp3&AudioStreamIndex=1&VideoBitrate=2616000&AudioBitrate=384000&PlaySessionId=b9453a6c27ca461d9a08719f1f7db1a9&CopyTimestamps=true&RequireAvc=false&Tag=139a6c69469c4c7035f0ab5765c3602e&SegmentContainer=ts&MinSegments=2&BreakOnNonKeyFrames=True&h264-profile=high,main,baseline,constrainedbaseline&h264-level=51&hevc-profile=Main,Main10&ac3-audiochannels=8&eac3-audiochannels=8&aac-audiochannels=8&mp3-audiochannels=8&TranscodeReasons=ContainerBitrateExceedsLimit. User-Agent=Emby/1.6.15g (Linux;Android 7.0) ExoPlayerLib/2.8.1/Emby, Host=192.168.0.13:8096, Connection=Keep-Alive, Accept-Encoding=gzip [17:34:50] [INF] HTTP Response 200 to 192.168.0.15. Time: 119ms. http://192.168.0.13:8096/emby/videos/eb419be0-721a-19b4-e2a0-96edcb5a368a/main.m3u8?DeviceId=aee2029c13980366&MediaSourceId=eb419be0721a19b4e2a096edcb5a368a&VideoCodec=h264,mpeg2video,hevc,h265&AudioCodec=ac3,eac3,aac,mp3&AudioStreamIndex=1&VideoBitrate=2616000&AudioBitrate=384000&PlaySessionId=b9453a6c27ca461d9a08719f1f7db1a9&CopyTimestamps=true&RequireAvc=false&Tag=139a6c69469c4c7035f0ab5765c3602e&SegmentContainer=ts&MinSegments=2&BreakOnNonKeyFrames=True&h264-profile=high,main,baseline,constrainedbaseline&h264-level=51&hevc-profile=Main,Main10&ac3-audiochannels=8&eac3-audiochannels=8&aac-audiochannels=8&mp3-audiochannels=8&TranscodeReasons=ContainerBitrateExceedsLimit [17:34:50] [INF] HTTP GET http://192.168.0.13:8096/emby/videos/eb419be0-721a-19b4-e2a0-96edcb5a368a/hls1/main/0.ts?DeviceId=aee2029c13980366&MediaSourceId=eb419be0721a19b4e2a096edcb5a368a&VideoCodec=h264,mpeg2video,hevc,h265&AudioCodec=ac3,eac3,aac,mp3&AudioStreamIndex=1&VideoBitrate=2616000&AudioBitrate=384000&PlaySessionId=b9453a6c27ca461d9a08719f1f7db1a9&CopyTimestamps=true&RequireAvc=false&Tag=139a6c69469c4c7035f0ab5765c3602e&SegmentContainer=ts&MinSegments=2&BreakOnNonKeyFrames=True&h264-profile=high,main,baseline,constrainedbaseline&h264-level=51&hevc-profile=Main,Main10&ac3-audiochannels=8&eac3-audiochannels=8&aac-audiochannels=8&mp3-audiochannels=8&TranscodeReasons=ContainerBitrateExceedsLimit. User-Agent=Emby/1.6.15g (Linux;Android 7.0) ExoPlayerLib/2.8.1/Emby, Accept-Encoding=identity, Host=192.168.0.13:8096, Connection=Keep-Alive [17:34:50] [INF] /config/customffmpeg/ffmpeg-git-20190107-amd64-static/ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 -i file:"/media/Movies/Summer '03 (2018)/Summer '03 (2018) [WEB-DL].mkv" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_vaapi -b:v 2616000 -maxrate 2616000 -bufsize 5232000 -profile:v 578 -level 41 -force_key_frames "expr:gte(t,n_forced*3)" -vf "format=nv12|vaapi,hwupload,scale_vaapi=w=1280:h=608" -copyts -vsync -1 -codec:a:0 copy -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3 -individual_header_trailer 0 -segment_format mpegts -segment_list_type m3u8 -segment_start_number 0 -segment_list "/media/dri/transcoding-temp/transcoding-temp/1228ae4ede026b0f991088d2ee3cdfe6.m3u8" -y "/media/dri/transcoding-temp/transcoding-temp/1228ae4ede026b0f991088d2ee3cdfe6%d.ts" [17:34:50] [INF] FFMpeg exited with code 1 [17:34:50] [INF] returning /media/dri/transcoding-temp/transcoding-temp/1228ae4ede026b0f991088d2ee3cdfe60.ts [17:35:11] [ERR] Error in BeginListeningForBroadcasts System.Net.Sockets.SocketException (98): Address already in use at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName) at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.Bind(EndPoint localEP) at Emby.Server.Implementations.Net.UdpSocket..ctor(Socket socket, Int32 localPort, IPAddress ip) in /repo/Emby.Server.Implementations/Net/UdpSocket.cs:line 47 at Emby.Server.Implementations.Net.SocketFactory.CreateUdpMulticastSocket(String ipAddress, Int32 multicastTimeToLive, Int32 localPort) in /repo/Emby.Server.Implementations/Net/SocketFactory.cs:line 183 at Rssdp.Infrastructure.SsdpCommunicationsServer.ListenForBroadcastsAsync() in /repo/RSSDP/SsdpCommunicationsServer.cs:line 350 at Rssdp.Infrastructure.SsdpCommunicationsServer.BeginListeningForBroadcasts() in /repo/RSSDP/SsdpCommunicationsServer.cs:line 126` `http://192.168.0.13:8096/emby/videos/eb419be0-721a-19b4-e2a0-96edcb5a368a/hls1/main/0.ts?DeviceId=aee2029c13980366&MediaSourceId=eb419be0721a19b4e2a096edcb5a368a&VideoCodec=h264,mpeg2video,hevc,h265&AudioCodec=ac3,eac3,aac,mp3&AudioStreamIndex=1&VideoBitrate=2616000&AudioBitrate=384000&PlaySessionId=b9453a6c27ca461d9a08719f1f7db1a9&api_key=be595dc7fcdb44329b3b326ffb8444ec&CopyTimestamps=true&RequireAvc=false&Tag=139a6c69469c4c7035f0ab5765c3602e&SegmentContainer=ts&MinSegments=2&BreakOnNonKeyFrames=True&h264-profile=high,main,baseline,constrainedbaseline&h264-level=51&hevc-profile=Main,Main10&ac3-audiochannels=8&eac3-audiochannels=8&aac-audiochannels=8&mp3-audiochannels=8&TranscodeReasons=ContainerBitrateExceedsLimit {"Protocol":"File","Id":"eb419be0721a19b4e2a096edcb5a368a","Path":"/media/Movies/Summer '03 (2018)/Summer '03 (2018) [WEB-DL].mkv","Type":"Default","Container":"mkv,webm","Name":"Summer '03 (2018) [WEB-DL]","IsRemote":false,"ETag":"139a6c69469c4c7035f0ab5765c3602e","RunTimeTicks":57133441024,"ReadAtNativeFramerate":false,"IgnoreDts":false,"IgnoreIndex":false,"GenPtsInput":false,"SupportsTranscoding":true,"SupportsDirectStream":true,"SupportsDirectPlay":true,"IsInfiniteStream":false,"RequiresOpening":false,"RequiresClosing":false,"RequiresLooping":false,"SupportsProbing":true,"VideoType":"VideoFile","MediaStreams":[{"Codec":"h264","Language":"eng","TimeBase":"1/1000","CodecTimeBase":"1001/48000","Title":"Summer.03.2018.1080p.WEB-DL.DD5.1.H264-FGT","VideoRange":"SDR","DisplayTitle":"1080P H264","NalLengthSize":"4","IsInterlaced":false,"IsAVC":true,"BitRate":4962891,"BitDepth":8,"RefFrames":1,"IsDefault":true,"IsForced":false,"Height":908,"Width":1908,"AverageFrameRate":23.9760246,"RealFrameRate":23.9760246,"Profile":"High","Type":"Video","AspectRatio":"477:227","Index":0,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"PixelFormat":"yuv420p","Level":40},{"Codec":"ac3","Language":"eng","TimeBase":"1/1000","CodecTimeBase":"1/48000","Title":"Summer.03.2018.1080p.WEB-DL.DD5.1.H264-FGT","DisplayTitle":"Eng Dolby Digital 5.1 Default","IsInterlaced":false,"ChannelLayout":"5.1","BitRate":384000,"Channels":6,"SampleRate":48000,"IsDefault":true,"IsForced":false,"Type":"Audio","Index":1,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Level":0},{"Codec":"mjpeg","TimeBase":"1/90000","CodecTimeBase":"0/1","IsInterlaced":false,"BitDepth":8,"RefFrames":1,"IsDefault":false,"IsForced":false,"Height":176,"Width":120,"RealFrameRate":90000,"Profile":"Baseline","Type":"EmbeddedImage","Index":2,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"PixelFormat":"yuvj444p","Level":-99},{"Codec":"mjpeg","TimeBase":"1/90000","CodecTimeBase":"0/1","IsInterlaced":false,"BitDepth":8,"RefFrames":1,"IsDefault":false,"IsForced":false,"Height":120,"Width":213,"RealFrameRate":90000,"Profile":"Baseline","Type":"EmbeddedImage","AspectRatio":"16:9","Index":3,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"PixelFormat":"yuvj444p","Level":-99},{"Codec":"mjpeg","TimeBase":"1/90000","CodecTimeBase":"0/1","IsInterlaced":false,"BitDepth":8,"RefFrames":1,"IsDefault":false,"IsForced":false,"Height":882,"Width":600,"RealFrameRate":90000,"Profile":"Baseline","Type":"EmbeddedImage","Index":4,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"PixelFormat":"yuvj444p","Level":-99},{"Codec":"mjpeg","TimeBase":"1/90000","CodecTimeBase":"0/1","IsInterlaced":false,"BitDepth":8,"RefFrames":1,"IsDefault":false,"IsForced":false,"Height":600,"Width":1067,"RealFrameRate":90000,"Profile":"Baseline","Type":"EmbeddedImage","AspectRatio":"16:9","Index":5,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"PixelFormat":"yuvj444p","Level":-99}],"Formats":[],"Bitrate":5346891,"RequiredHttpHeaders":{}} /config/customffmpeg/ffmpeg-git-20190107-amd64-static/ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 -i file:"/media/Movies/Summer '03 (2018)/Summer '03 (2018) [WEB-DL].mkv" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_vaapi -b:v 2616000 -maxrate 2616000 -bufsize 5232000 -profile:v 578 -level 41 -force_key_frames "expr:gte(t,n_forced*3)" -vf "format=nv12|vaapi,hwupload,scale_vaapi=w=1280:h=608" -copyts -vsync -1 -codec:a:0 copy -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3 -individual_header_trailer 0 -segment_format mpegts -segment_list_type m3u8 -segment_start_number 0 -segment_list "/media/dri/transcoding-temp/transcoding-temp/1228ae4ede026b0f991088d2ee3cdfe6.m3u8" -y "/media/dri/transcoding-temp/transcoding-temp/1228ae4ede026b0f991088d2ee3cdfe6%d.ts" ffmpeg version N-47944-g038d291b70-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2019 the FFmpeg developers ```
BobOkisama commented 5 years ago

I just emailed Van asking if the 4.1 static build he has includes NVenc/NVdec and VAAPI. Hopefully I will hear back from him soon, and maybe if it does not get him to do one with those baked in.

Also, as far as I can tell from the logs when I have nvidia transcode enabled, does not look like it is even passing the commands to use it:

/opt/ffmpeg/ffmpeg-4.1-64bit-static/ffmpeg -i file:"/media/boboki/Media/BobOki/4K/Arrival.2016.2160p.Remux.UHD.BluRay.HDR.DTS-HD.MA7.1.x265-UHDCL.mp4" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 libx264 -pix_fmt yuv420p -preset veryfast -crf 21 -maxrate 2616000 -bufsize 5232000 -profile:v high -level 4.1 -x264opts:0 subme=0:me_range=4:rc_lookahead=10:me=dia:no_chroma_me:8x8dct=0:partitions=none -force_key_frames "expr:gte(t,n_forced*3)" -vf "scale=trunc(min(max(iw\,ih*dar)\,1280)/2)*2:trunc(ow/dar/2)*2" -copyts -vsync -1 -codec:a:0 libmp3lame -ac 2 -ab 384000 -af "volume=2" -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3  -individual_header_trailer 0 -segment_format mpegts -segment_list_type m3u8 -segment_start_number 0 -segment_list "/tmp/transcoding-temp/bc48ad2f04a6257b2553f1d2be5d3318.m3u8" -y "/tmp/transcoding-temp/bc48ad2f04a6257b2553f1d2be5d3318%d.ts"

I expect to see a h264_nvenc/h265_nvenc or -hwaccel nvdec in that command, but unless I am blind I am not. I did just change my preset to slow and I show that being used in the command, but still no NV commands.

BobOkisama commented 5 years ago

Got a reply from Van:

It's not possible to statically link to vaapi or NVidia's driver because they only ship shared libs.

Well, things got more interesting now.

BobOkisama commented 5 years ago

I did verify that jellyfin is not passing the proper CLI commands to ffmpeg for nvenc/nvdec transcoding in linux. On my test box which is win10 I enabled nvidia transcode (1080ti on that machine) and here is the command line passed:

D:\Jellyfin-server\ffmpeg.exe -c:v hevc_cuvid  -resize 1278x534 -i file:"M:\BobOki\4K\Avengers.Infinity.War.2018.2160p.UHD.BluRay.x265-TERMiNAL\avengers.infinity.war.2018.2160p.uhd.bluray.x265-terminal.mp4" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_nvenc -pix_fmt yuv420p -preset default -b:v 3360000 -maxrate 3360000 -bufsize 6720000 -profile:v high -force_key_frames "expr:gte(t,n_forced*3)" -copyts -vsync -1 -codec:a:0 libmp3lame -ac 2 -ab 384000  -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3  -individual_header_trailer 0 -segment_format mpegts -segment_list_type m3u8 -segment_start_number 0 -segment_list "C:\Users\bobok\AppData\Roaming\jellyfin\transcoding-temp\2b2ab34e680117a83c1659f605a1d80e.m3u8" -y "C:\Users\bobok\AppData\Roaming\jellyfin\transcoding-temp\2b2ab34e680117a83c1659f605a1d80e%d.ts"

You can see the -codec:v:0 h264_nvec and -c:v hevc_cuvid string being called. I see about 11% cpu in use and a solid crazy like 85% GPU. Mind you this is not my P2000 and I do not have any patched drivers loaded for this card, but it certainly is passing the proper commands.

JustAMan commented 5 years ago

cc @MatMaul

MatMaul commented 5 years ago

Hum I think the GPL christmas gift breaks it. It looks like MediaController.MediaEncoding get removed and completely replaced ? I'll have a look tomorrow, for now I don't even know where I can find the previous version to diff it, some history got rewritten right ? @nvllsvm I need your help here, if you have some way to get or an archive of the repo before chritmas I would be helpful.

JustAMan commented 5 years ago

@MatMaul how about https://github.com/MatMaul/jellyfin 😃 ?

MatMaul commented 5 years ago

... I think I need to go to sleep xD I erased my local branches after the force push, didn't think about my remote ^^ Thanks !

Aterfax commented 5 years ago

Don't you need to install the nvidia GPU and CUDA drivers on both the host and in the docker image for this to work?

i.e. https://stackoverflow.com/questions/25185405/using-gpu-from-a-docker-container

Or using the nvidia-docker ?

Aterfax commented 5 years ago

Updated to current and tested and working on Unraid, Dockerfile to build an image:

i.e. - docker build -t imagename .

FROM ubuntu:16.04
MAINTAINER Jonathan Kosgei <jonathan@saharacluster.com>

# A docker container with the Nvidia kernel module and CUDA drivers installed

ENV CUDA_RUN https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda_10.0.130_410.48_linux

RUN apt-get update && apt-get install -q -y \
  wget \
  module-init-tools \
  build-essential 

RUN cd /opt && \
  wget $CUDA_RUN && \
  chmod +x cuda_10.0.130_410.48_linux && \
  mkdir nvidia_installers && \
  ./cuda_10.0.130_410.48_linux -extract=`pwd`/nvidia_installers && \
  cd nvidia_installers && \
  ./NVIDIA-Linux-x86_64-410.48.run -s -N --no-kernel-module

RUN cd /opt/nvidia_installers && ls -alh && \
  ./cuda-linux.10.0.130-24817639.run -noprompt

# Ensure the CUDA libs and binaries are in the correct environment variables
ENV LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-10.0/lib64
ENV PATH=$PATH:/usr/local/cuda-10.0/bin

RUN cd /opt/nvidia_installers &&\
    ./cuda-samples.10.0.130-24817639-linux.run -noprompt -cudaprefix=/usr/local/cuda-10.0 &&\
    cd /usr/local/cuda/samples/1_Utilities/deviceQuery &&\ 
    make

WORKDIR /usr/local/cuda/samples/1_Utilities/deviceQuery

Now run the image and test:

sudo docker run -ti --device /dev/nvidia0:/dev/nvidia0 --device /dev/nvidiactl:/dev/nvidiactl --device /dev/nvidia-uvm:/dev/nvidia-uvm <built-image> ./deviceQuery

You should see output similar to:

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 8.0, CUDA Runtime Version = 8.0, NumDevs = 1, Device0 = GRID K520
Result = PASS
Aterfax commented 5 years ago

Also yes, ffmpeg in the docker does not appear to support NVENC so we might want to raise an issue for them to include an ffmpeg that does.

BobOkisama commented 5 years ago

Just found out that the latest ffmpeg in the 18.04 ubuntu repo (3.4.4-0ubuntu0.18.04.1) does have nvenc and nvdec/cuda. I am running 16.04 so this does not help me.... yet.

Anyone know a way to load that same ffmpeg package on 16.04?

Aterfax commented 5 years ago

You would need to compile ffmpeg with that support turned on.

Aterfax commented 5 years ago

Has there been any further development on this?

Depending on the docker image base operating system integrating the nvidia packages may be extremely straightforward * assuming it is the same OS as one of the nvidia provided pre-made images.

Here's how they make their own images: https://gitlab.com/nvidia/cuda/blob/ubuntu16.04/10.0/base/Dockerfile

cvium commented 5 years ago

cc @nvllsvm @sparky8251

Aterfax commented 5 years ago

On further investigation - it looks like the docker might simply need to package an FFMPEG compiled with NVENC support for the acceleration to work*

*But the CUDA SDK versions need to match from the host to the version FFMPEG is compiled with!

fhriley commented 5 years ago

I'm running jellyfin in docker, and this already works. You just need to make sure you have the nvidia drivers installed and nvidia-docker set up properly. Then set the runtime to nvidia for your docker container. Here is my docker-compose for my jellyfin container:

jellyfin:
    image: jellyfin/jellyfin
    container_name: jellyfin
    hostname: jellyfin
    runtime: nvidia
    restart: always
    ports:
      - '8096:8096/tcp'
    volumes:
      - /zfs/docker/appdata/jellyfin:/config
      - /mnt/ssd/cache:/cache
      - /zfs/media:/media
    environment:
      - NVIDIA_VISIBLE_DEVICES=all
      - NVIDIA_DRIVER_CAPABILITIES=compute,video,utility
    devices:
      - "/dev/dri:/dev/dri"

I don't think the /dev/dri is needed, but I have it in there just in case.

Aterfax commented 5 years ago

Are you saying the native Jellyfin container now has NVENC support in the FFMPEG package?

If so, which nvidia SDK was it built upon?

fhriley commented 5 years ago

Yes:

root@nas:~# docker exec -it jellyfin ffprobe -encoders | grep nvenc
  configuration: --disable-debug --disable-doc --disable-ffplay --enable-vaapi --enable-shared --enable-avresample --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gnutls --enable-gpl --enable-libass --enable-libfreetype --enable-libvidstab --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx265 --enable-libxvid --enable-libx264 --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-postproc --enable-cuvid --enable-nvenc --enable-version3 --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib --extra-libs=-ldl --prefix=/opt/ffmpeg
 V..... h264_nvenc           NVIDIA NVENC H.264 encoder (codec h264)
 V..... nvenc                NVIDIA NVENC H.264 encoder (codec h264)
 V..... nvenc_h264           NVIDIA NVENC H.264 encoder (codec h264)
 V..... nvenc_hevc           NVIDIA NVENC hevc encoder (codec hevc)
 V..... hevc_nvenc           NVIDIA NVENC hevc encoder (codec hevc)
root@nas:~# docker exec -it jellyfin ffprobe -decoders | grep cuvid
  configuration: --disable-debug --disable-doc --disable-ffplay --enable-vaapi --enable-shared --enable-avresample --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gnutls --enable-gpl --enable-libass --enable-libfreetype --enable-libvidstab --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx265 --enable-libxvid --enable-libx264 --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-postproc --enable-cuvid --enable-nvenc --enable-version3 --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib --extra-libs=-ldl --prefix=/opt/ffmpeg
 V..... h264_cuvid           Nvidia CUVID H264 decoder (codec h264)
 V..... hevc_cuvid           Nvidia CUVID HEVC decoder (codec hevc)
 V..... mjpeg_cuvid          Nvidia CUVID MJPEG decoder (codec mjpeg)
 V..... mpeg1_cuvid          Nvidia CUVID MPEG1VIDEO decoder (codec mpeg1video)
 V..... mpeg2_cuvid          Nvidia CUVID MPEG2VIDEO decoder (codec mpeg2video)
 V..... mpeg4_cuvid          Nvidia CUVID MPEG4 decoder (codec mpeg4)
 V..... vc1_cuvid            Nvidia CUVID VC1 decoder (codec vc1)
 V..... vp8_cuvid            Nvidia CUVID VP8 decoder (codec vp8)
 V..... vp9_cuvid            Nvidia CUVID VP9 decoder (codec vp9)

I have no idea what nvidia SDK it was built against. If you have recent nvidia drivers installed, I doubt it matters. Here is what I have:

root@nas:~# nvidia-smi
Sun May 26 11:30:38 2019
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.56       Driver Version: 418.56       CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce RTX 2060    Off  | 00000000:03:00.0 Off |                  N/A |
| 12%   55C    P0     1W / 190W |      0MiB /  5904MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
Aterfax commented 5 years ago

Yes:

root@nas:~# docker exec -it jellyfin ffprobe -encoders | grep nvenc
  configuration: --disable-debug --disable-doc --disable-ffplay --enable-vaapi --enable-shared --enable-avresample --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gnutls --enable-gpl --enable-libass --enable-libfreetype --enable-libvidstab --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx265 --enable-libxvid --enable-libx264 --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-postproc --enable-cuvid --enable-nvenc --enable-version3 --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib --extra-libs=-ldl --prefix=/opt/ffmpeg
 V..... h264_nvenc           NVIDIA NVENC H.264 encoder (codec h264)
 V..... nvenc                NVIDIA NVENC H.264 encoder (codec h264)
 V..... nvenc_h264           NVIDIA NVENC H.264 encoder (codec h264)
 V..... nvenc_hevc           NVIDIA NVENC hevc encoder (codec hevc)
 V..... hevc_nvenc           NVIDIA NVENC hevc encoder (codec hevc)
root@nas:~# docker exec -it jellyfin ffprobe -decoders | grep cuvid
  configuration: --disable-debug --disable-doc --disable-ffplay --enable-vaapi --enable-shared --enable-avresample --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gnutls --enable-gpl --enable-libass --enable-libfreetype --enable-libvidstab --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx265 --enable-libxvid --enable-libx264 --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-postproc --enable-cuvid --enable-nvenc --enable-version3 --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib --extra-libs=-ldl --prefix=/opt/ffmpeg
 V..... h264_cuvid           Nvidia CUVID H264 decoder (codec h264)
 V..... hevc_cuvid           Nvidia CUVID HEVC decoder (codec hevc)
 V..... mjpeg_cuvid          Nvidia CUVID MJPEG decoder (codec mjpeg)
 V..... mpeg1_cuvid          Nvidia CUVID MPEG1VIDEO decoder (codec mpeg1video)
 V..... mpeg2_cuvid          Nvidia CUVID MPEG2VIDEO decoder (codec mpeg2video)
 V..... mpeg4_cuvid          Nvidia CUVID MPEG4 decoder (codec mpeg4)
 V..... vc1_cuvid            Nvidia CUVID VC1 decoder (codec vc1)
 V..... vp8_cuvid            Nvidia CUVID VP8 decoder (codec vp8)
 V..... vp9_cuvid            Nvidia CUVID VP9 decoder (codec vp9)

I have no idea what nvidia SDK it was built against. If you have recent nvidia drivers installed, I doubt it matters. Here is what I have:

root@nas:~# nvidia-smi
Sun May 26 11:30:38 2019
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.56       Driver Version: 418.56       CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce RTX 2060    Off  | 00000000:03:00.0 Off |                  N/A |
| 12%   55C    P0     1W / 190W |      0MiB /  5904MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

Thank-you for the clarification.

It might matter for some people as desync between the CUDA libraries used in the driver and those for FFMPEG compiling will result in errors, see:

https://github.com/binhex/arch-jellyfin/issues/2#issuecomment-485604637

https://devtalk.nvidia.com/default/topic/1044184/driver-does-not-support-the-required-nvenc-api-version-required-8-2-found-8-1/

JustAMan commented 5 years ago

We ship nvdec/nvenc-enabled ffmpeg in our docker builds for quite a while. What you really have to do is to make sure you use nvidia-enabled "docker driver" for running the container, but this is out of scope (at best it warrants a section in the JF documentation).

Aterfax commented 5 years ago

I think there should at least be a note of which SDK/driver the ffmpeg is compiled against for the reasons I said above.

JustAMan commented 5 years ago

Does the build script count for noting?

We have https://github.com/jellyfin/jellyfin-ffmpeg/blob/da7926e288225eafe1fca326e2fdd3a9e19785fc/docker/Dockerfile#L35 :

ARG         NVCODECHEADERS_VERSION=n9.0.18.1
Aterfax commented 5 years ago

I guess that works when people know where to look :)

I was thinking more documentation with a link to it or similar.

JustAMan commented 5 years ago

If you have an idea how to document it (and as you now know the version), could you please open a PR at https://github.com/jellyfin/jellyfin-docs with proposed changes?

Aterfax commented 5 years ago

I'd probably stick a paragraph of something in here: https://jellyfin.readthedocs.io/en/latest/administrator-docs/hardware-acceleration/#enabling-hardware-acceleration

"Hardware acceleration in Docker Containers" for example.

But again - I'm not familiar with how Jellyfin is doing documentation though if I get the time I will look into it.

anthonylavado commented 5 years ago

I'd probably stick a paragraph of something in here: https://jellyfin.readthedocs.io/en/latest/administrator-docs/hardware-acceleration/#enabling-hardware-acceleration ...

@Aterfax ah that’s our old docs page. Everything is now on docs.jellyfin.org. The repo that @JustAMan linked will publish there.