jellyfin / jellyfin-ffmpeg

FFmpeg for Jellyfin
https://jellyfin.org
Other
432 stars 115 forks source link

DG1 cannot HW-Accelerated decoding on Ubuntu 23.10 #371

Closed Hiyajomaho-num9 closed 3 months ago

Hiyajomaho-num9 commented 3 months ago

Describe The Bug I attempted to perform hardware decoding on Ubuntu 22.04, but ffmpeg reported an error "double free or corruption (!prev)". Therefore, I attempted to run Jellyfin on Ubuntu 23.10, but still encountered an error during hardware decoding. It seems like a driver issue, but I can't find an answer on Google.

System (please complete the following information):

MediaInfo

General
Complete name                            : Dark Gathering - S01E01 - Yayoi Hozuki WEBDL-1080p.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 664 MiB
Duration                                 : 23 min 42 s
Overall bit rate                         : 3 916 kb/s
Frame rate                               : 23.976 FPS
Writing application                      : Lilith Remuxer (https://t.me/lilithraws)

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L5
Format settings                          : CABAC / 4 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 4 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 23 min 42 s
Bit rate                                 : 3 603 kb/s
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 23.976 (24000/1001) FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.072
Stream size                              : 611 MiB (92%)
Writing library                          : x264 core 161 r3018 db0d417
Encoding settings                        : cabac=1 / ref=4 / deblock=1:-1:-1 / analyse=0x3:0x113 / me=umh / subme=9 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=24 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=8 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc_lookahead=50 / rc=crf / mbtree=1 / crf=21.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / vbv_maxrate=12000 / vbv_bufsize=80000 / crf_max=0.0 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=3:1.00
Codec configuration box                  : avcC

Audio
ID                                       : 2
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 23 min 42 s
Bit rate mode                            : Constant
Bit rate                                 : 308 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 52.2 MiB (8%)
Language                                 : Japanese
Default                                  : Yes
Alternate group                          : 1

FFmpeg Logs

/videos/8dcb6895-cef5-7fa5-ef24-46ad73665ced/hls1/main/1.ts

{"Protocol":0,"Id":"8dcb6895cef57fa5ef2446ad73665ced","Path":"/mnt/disk2/video_2/anime_2/Dark Gathering/Season 1/Dark Gathering - S01E01 - Yayoi Hozuki WEBDL-1080p.mp4","EncoderPath":null,"EncoderProtocol":null,"Type":0,"Container":"mov,mp4,m4a,3gp,3g2,mj2","Size":696034496,"Name":"Dark Gathering - S01E01 - Yayoi Hozuki WEBDL-1080p","IsRemote":false,"ETag":"aca676667cbb3b6e1d3a3e3132369ed3","RunTimeTicks":14220587008,"ReadAtNativeFramerate":false,"IgnoreDts":false,"IgnoreIndex":false,"GenPtsInput":false,"SupportsTranscoding":true,"SupportsDirectStream":true,"SupportsDirectPlay":true,"IsInfiniteStream":false,"RequiresOpening":false,"OpenToken":null,"RequiresClosing":false,"LiveStreamId":null,"BufferMs":null,"RequiresLooping":false,"SupportsProbing":true,"VideoType":0,"IsoType":null,"Video3DFormat":null,"MediaStreams":[{"Codec":"h264","CodecTag":"avc1","Language":"und","ColorRange":null,"ColorSpace":null,"ColorTransfer":null,"ColorPrimaries":null,"DvVersionMajor":null,"DvVersionMinor":null,"DvProfile":null,"DvLevel":null,"RpuPresentFlag":null,"ElPresentFlag":null,"BlPresentFlag":null,"DvBlSignalCompatibilityId":null,"Comment":null,"TimeBase":"1/24000","CodecTimeBase":null,"Title":null,"VideoRange":"SDR","VideoRangeType":"SDR","VideoDoViTitle":null,"LocalizedUndefined":null,"LocalizedDefault":null,"LocalizedForced":null,"LocalizedExternal":null,"DisplayTitle":"1080p H264 SDR","NalLengthSize":"4","IsInterlaced":false,"IsAVC":true,"ChannelLayout":null,"BitRate":3602819,"BitDepth":8,"RefFrames":1,"PacketLength":null,"Channels":null,"SampleRate":null,"IsDefault":true,"IsForced":false,"Height":1080,"Width":1920,"AverageFrameRate":23.976025,"RealFrameRate":23.976025,"Profile":"High","Type":1,"AspectRatio":"16:9","Index":0,"Score":null,"IsExternal":false,"DeliveryMethod":null,"DeliveryUrl":null,"IsExternalUrl":null,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Path":null,"PixelFormat":"yuv420p","Level":50,"IsAnamorphic":null},{"Codec":"aac","CodecTag":"mp4a","Language":"jpn","ColorRange":null,"ColorSpace":null,"ColorTransfer":null,"ColorPrimaries":null,"DvVersionMajor":null,"DvVersionMinor":null,"DvProfile":null,"DvLevel":null,"RpuPresentFlag":null,"ElPresentFlag":null,"BlPresentFlag":null,"DvBlSignalCompatibilityId":null,"Comment":null,"TimeBase":"1/48000","CodecTimeBase":null,"Title":null,"VideoRange":null,"VideoRangeType":null,"VideoDoViTitle":null,"LocalizedUndefined":null,"LocalizedDefault":null,"LocalizedForced":null,"LocalizedExternal":null,"DisplayTitle":"Japanese - AAC - Stereo - Default","NalLengthSize":null,"IsInterlaced":false,"IsAVC":null,"ChannelLayout":"stereo","BitRate":307879,"BitDepth":null,"RefFrames":null,"PacketLength":null,"Channels":2,"SampleRate":48000,"IsDefault":true,"IsForced":false,"Height":null,"Width":null,"AverageFrameRate":null,"RealFrameRate":null,"Profile":"LC","Type":0,"AspectRatio":null,"Index":1,"Score":null,"IsExternal":false,"DeliveryMethod":null,"DeliveryUrl":null,"IsExternalUrl":null,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Path":null,"PixelFormat":null,"Level":0,"IsAnamorphic":null}],"MediaAttachments":[],"Formats":[],"Bitrate":3915644,"Timestamp":null,"RequiredHttpHeaders":{},"TranscodingUrl":null,"TranscodingSubProtocol":null,"TranscodingContainer":null,"AnalyzeDurationMs":null,"DefaultAudioStreamIndex":null,"DefaultSubtitleStreamIndex":null}

/usr/lib/jellyfin-ffmpeg/ffmpeg -analyzeduration 200M -probesize 1G -ss 00:00:04.000 -init_hw_device vaapi=va:,kernel_driver=i915,driver=iHD -init_hw_device qsv=qs@va -filter_hw_device qs -hwaccel vaapi -hwaccel_output_format vaapi -autorotate 0 -i file:"/mnt/disk2/video_2/anime_2/Dark Gathering/Season 1/Dark Gathering - S01E01 - Yayoi Hozuki WEBDL-1080p.mp4" -autoscale 0 -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_qsv -preset veryfast -look_ahead 0 -b:v 412121 -maxrate 412121 -bufsize 824242 -profile:v:0 high -level 50 -g:v:0 96 -keyint_min:v:0 96 -vf "setparams=color_primaries=bt709:color_trc=bt709:colorspace=bt709,scale_vaapi=w=640:h=360:format=nv12:extra_hw_frames=24,hwmap=derive_device=qsv,format=qsv" -codec:a:0 libfdk_aac -ac 2 -ab 256000 -ar 48000 -copyts -avoid_negative_ts disabled -max_muxing_queue_size 2048 -f hls -max_delay 5000000 -hls_time 4 -hls_segment_type mpegts -start_number 1 -hls_segment_filename "/config/transcodes/af367de7b09adeeef12e9e3931cb3f13%d.ts" -hls_playlist_type vod -hls_list_size 0 -y "/config/transcodes/af367de7b09adeeef12e9e3931cb3f13.m3u8"

ffmpeg version 6.0.1-Jellyfin Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12 (Debian 12.2.0-14)
  configuration: --prefix=/usr/lib/jellyfin-ffmpeg --target-os=linux --extra-version=Jellyfin --disable-doc --disable-ffplay --disable-ptx-compression --disable-static --disable-libxcb --disable-sdl2 --disable-xlib --enable-lto --enable-gpl --enable-version3 --enable-shared --enable-gmp --enable-gnutls --enable-chromaprint --enable-opencl --enable-libdrm --enable-libass --enable-libfreetype --enable-libfribidi --enable-libfontconfig --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libopenmpt --enable-libdav1d --enable-libsvtav1 --enable-libwebp --enable-libvpx --enable-libx264 --enable-libx265 --enable-libzvbi --enable-libzimg --enable-libfdk-aac --arch=amd64 --enable-libshaderc --enable-libplacebo --enable-vulkan --enable-vaapi --enable-amf --enable-libvpl --enable-ffnvcodec --enable-cuda --enable-cuda-llvm --enable-cuvid --enable-nvdec --enable-nvenc
  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
libva info: VA-API version 1.20.0
libva info: Trying to open /usr/lib/jellyfin-ffmpeg/lib/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_20
libva info: va_openDriver() returns 0
libva info: VA-API version 1.20.0
libva info: Trying to open /usr/lib/jellyfin-ffmpeg/lib/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_20
libva info: va_openDriver() returns 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file:/mnt/disk2/video_2/anime_2/Dark Gathering/Season 1/Dark Gathering - S01E01 - Yayoi Hozuki WEBDL-1080p.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lilith Remuxer (https://t.me/lilithraws)
  Duration: 00:23:42.06, start: 0.000000, bitrate: 3915 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 3602 kb/s, 23.98 fps, 23.98 tbr, 24k tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](jpn): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 307 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_qsv))
  Stream #0:1 -> #0:1 (aac (native) -> aac (libfdk_aac))
Press [q] to stop, [?] for help
[h264 @ 0x56a5dbdb9380] Failed to end picture decode issue: 23 (internal decoding error).
[h264 @ 0x56a5dbdb9380] hardware accelerator failed to decode picture
[h264 @ 0x56a5dbe0c6c0] Failed to end picture decode issue: 23 (internal decoding error).
[h264 @ 0x56a5dbe0c6c0] hardware accelerator failed to decode picture
[h264 @ 0x56a5dbe2dbc0] Failed to end picture decode issue: 23 (internal decoding error).
[h264 @ 0x56a5dbe2dbc0] hardware accelerator failed to decode picture
[h264 @ 0x56a5dc511e40] Failed to end picture decode issue: 23 (internal decoding error).
[h264 @ 0x56a5dc511e40] hardware accelerator failed to decode picture
[h264 @ 0x56a5dc526900] Failed to end picture decode issue: 23 (internal decoding error).
[h264 @ 0x56a5dc526900] hardware accelerator failed to decode picture
[h264 @ 0x56a5dc53b380] Failed to end picture decode issue: 23 (internal decoding error).
[h264 @ 0x56a5dc53b380] hardware accelerator failed to decode picture
[h264 @ 0x56a5dc553340] Failed to end picture decode issue: 23 (internal decoding error).
[h264 @ 0x56a5dc553340] hardware accelerator failed to decode picture
[h264 @ 0x56a5dc567ac0] Failed to end picture decode issue: 23 (internal decoding error).
[h264 @ 0x56a5dc567ac0] hardware accelerator failed to decode picture
[h264 @ 0x56a5dc57c480] Failed to end picture decode issue: 23 (internal decoding error).
[h264 @ 0x56a5dc57c480] hardware accelerator failed to decode picture
[h264 @ 0x56a5dc590f00] Failed to end picture decode issue: 23 (internal decoding error).
[h264 @ 0x56a5dc590f00] hardware accelerator failed to decode picture
[h264 @ 0x56a5dc5a5980] Failed to end picture decode issue: 23 (internal decoding error).
[h264 @ 0x56a5dc5a5980] hardware accelerator failed to decode picture
[h264 @ 0x56a5dc5ba380] Failed to end picture decode issue: 23 (internal decoding error).
[h264 @ 0x56a5dc5ba380] hardware accelerator failed to decode picture
Error while decoding stream #0:0: Input/output error
    Last message repeated 1 times

Additional Context

Dmesg


[    4.635075] i915 0000:08:00.0: Force probing unsupported Device ID 4908, tainting kernel
[    4.635572] i915 0000:08:00.0: [drm] VT-d active for gfx access
[    4.635785] i915 0000:08:00.0: vgaarb: deactivate vga console
[    4.635823] i915 0000:08:00.0: [drm] Local memory IO size: 0x00000000fb800000
[    4.635825] i915 0000:08:00.0: [drm] Local memory available: 0x00000000fb800000
[    4.662551] i915 0000:08:00.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=io+mem:owns=none
[    4.665420] i915 0000:08:00.0: [drm] Finished loading DMC firmware i915/dg1_dmc_ver2_02.bin (v2.2)
[    4.672704] i915 0000:08:00.0: [drm] GT0: GuC firmware i915/dg1_guc_70.bin version 70.5.1
[    4.672708] i915 0000:08:00.0: [drm] GT0: HuC firmware i915/dg1_huc.bin version 7.9.3
[    4.678278] i915 0000:08:00.0: [drm] GT0: HuC: authenticated for all workloads
[    4.678631] i915 0000:08:00.0: [drm] GT0: GUC: submission enabled
[    4.678634] i915 0000:08:00.0: [drm] GT0: GUC: SLPC enabled
[    4.678844] i915 0000:08:00.0: [drm] GT0: GUC: RC enabled
[    4.701927] [drm] Initialized i915 1.6.0 20201103 for 0000:08:00.0 on minor 0
[    4.702249] snd_hda_intel 0000:09:00.0: bound 0000:08:00.0 (ops i915_audio_component_bind_ops [i915])
[    4.793811] fbcon: i915drmfb (fb0) is primary device
[    4.856390] i915 0000:08:00.0: [drm] fb0: i915drmfb frame buffer device

i915.conf

options i915 enable_guc=3
options i915 force_probe=4908
nyanmisaka commented 3 months ago

DG1 is not fully supported yet in the i915 kernel driver of mainline Linux. Especially when it comes to video decoding, encoding and processing.