jellyfin / jellyfin-ffmpeg

FFmpeg for Jellyfin
https://jellyfin.org
Other
438 stars 119 forks source link

Apple HEVC movies with Intel QSV and Intel 12th Gen i5 #271

Closed svenger87 closed 9 months ago

svenger87 commented 11 months ago

Describe The Bug I use a ProxMox Host with the above mentioned CPU. The VM Host has IOMMU enabled and i split the GPU into 6 VF´s from which I pass one VF to a LXC container.

En and Decoding works for most of the video files I need to transcode except for Apple HEVC encoded files. See ffprobe and ffmpeg output below.

Expected Behavior Let ffpeg encode the file.

System (please complete the following information):

MediaInfo

./ffprobe /mnt/immich/immich-data/library/sven/2022/2022-02/IMG_0746.MOV
ffprobe version 5.1.3-Jellyfin Copyright (c) 2007-2022 the FFmpeg developers
  built with gcc 12 (Ubuntu 12.2.0-3ubuntu1)
  configuration: --prefix=/usr/lib/jellyfin-ffmpeg --target-os=linux --extra-libs=-lfftw3f --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-libdrm --enable-libass --enable-libfreetype --enable-libfribidi --enable-libfontconfig --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libopenmpt --enable-libdav1d --enable-libwebp --enable-libvpx --enable-libx264 --enable-libx265 --enable-libzvbi --enable-libzimg --enable-libfdk-aac --arch=amd64 --enable-libsvtav1 --enable-libshaderc --enable-libplacebo --enable-vulkan --enable-opencl --enable-vaapi --enable-amf --enable-libmfx --enable-ffnvcodec --enable-cuda --enable-cuda-llvm --enable-cuvid --enable-nvdec --enable-nvenc
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/mnt/immich/immich-data/library/sven/2022/2022-02/IMG_0746.MOV':
  Metadata:
    major_brand     : qt  
    minor_version   : 0
    compatible_brands: qt  
    creation_time   : 2022-02-26T09:35:29.000000Z
    com.apple.quicktime.location.accuracy.horizontal: 3.535534
    com.apple.quicktime.location.ISO6709: +53.0678+007.2713+002.043/
    com.apple.quicktime.make: Apple
    com.apple.quicktime.model: iPhone 13 Pro
    com.apple.quicktime.software: 15.3.1
    com.apple.quicktime.creationdate: 2022-02-26T10:35:29+0100
  Duration: 00:00:09.62, start: 0.000000, bitrate: 51200 kb/s
  Stream #0:0[0x1](und): Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, bt709), 1920x1080, 50961 kb/s, 239.69 fps, 240 tbr, 2400 tbn (default)
    Metadata:
      creation_time   : 2022-02-26T09:35:29.000000Z
      handler_name    : Core Media Video
      vendor_id       : [0][0][0][0]
      encoder         : HEVC
    Side data:
      displaymatrix: rotation of -90.00 degrees
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 201 kb/s (default)
    Metadata:
      creation_time   : 2022-02-26T09:35:29.000000Z
      handler_name    : Core Media Audio
      vendor_id       : [0][0][0][0]

FFmpeg Logs

immich_microservices       | [Nest] 6  - 08/07/2023, 6:15:25 PM     LOG [MediaService] Start encoding video b66bc141-adb2-44b2-a089-c870e58c9c26 {"inputOptions":["-init_hw_device qsv=hw","-filter_hw_device hw"],"outputOptions":["-vcodec h264_qsv","-g 256","-extbrc 1","-refs 5","-bf 7","-acodec aac","-movflags faststart","-fps_mode passthrough","-v verbose","-vf format=nv12,hwupload=extra_hw_frames=64","-preset 4","-global_quality 23"],"twoPass":false}
immich_microservices       | [Nest] 6  - 08/07/2023, 6:15:26 PM   ERROR [MediaRepository] ffmpeg version 5.1.3-Jellyfin Copyright (c) 2000-2022 the FFmpeg developers
immich_microservices       |   built with gcc 12 (Ubuntu 12.2.0-3ubuntu1)
immich_microservices       |   configuration: --prefix=/usr/lib/jellyfin-ffmpeg --target-os=linux --extra-libs=-lfftw3f --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-libdrm --enable-libass --enable-libfreetype --enable-libfribidi --enable-libfontconfig --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libopenmpt --enable-libdav1d --enable-libwebp --enable-libvpx --enable-libx264 --enable-libx265 --enable-libzvbi --enable-libzimg --enable-libfdk-aac --arch=amd64 --enable-libsvtav1 --enable-libshaderc --enable-libplacebo --enable-vulkan --enable-opencl --enable-vaapi --enable-amf --enable-libmfx --enable-ffnvcodec --enable-cuda --enable-cuda-llvm --enable-cuvid --enable-nvdec --enable-nvenc
immich_microservices       |   libavutil      57. 28.100 / 57. 28.100
immich_microservices       |   libavcodec     59. 37.100 / 59. 37.100
immich_microservices       |   libavformat    59. 27.100 / 59. 27.100
immich_microservices       |   libavdevice    59.  7.100 / 59.  7.100
immich_microservices       |   libavfilter     8. 44.100 /  8. 44.100
immich_microservices       |   libswscale      6.  7.100 /  6.  7.100
immich_microservices       |   libswresample   4.  7.100 /  4.  7.100
immich_microservices       |   libpostproc    56.  6.100 / 56.  6.100
immich_microservices       | [AVHWDeviceContext @ 0x27fce180300] Trying to use DRM render node for device 0, with matching kernel driver (i915).
immich_microservices       | [AVHWDeviceContext @ 0x27fce180300] libva: VA-API version 1.19.0
immich_microservices       | [AVHWDeviceContext @ 0x27fce180300] libva: User requested driver 'iHD'
immich_microservices       | [AVHWDeviceContext @ 0x27fce180300] libva: Trying to open /usr/lib/jellyfin-ffmpeg/lib/dri/iHD_drv_video.so
immich_microservices       | [AVHWDeviceContext @ 0x27fce180300] libva: Found init function __vaDriverInit_1_19
immich_microservices       | [AVHWDeviceContext @ 0x27fce180300] libva: va_openDriver() returns 0
immich_microservices       | [AVHWDeviceContext @ 0x27fce180300] Initialised VAAPI connection: version 1.19
immich_microservices       | [AVHWDeviceContext @ 0x27fce180300] VAAPI driver: Intel iHD driver for Intel(R) Gen Graphics - 23.3.0 (919d398).
immich_microservices       | [AVHWDeviceContext @ 0x27fce180300] Driver not found in known nonstandard list, using standard behaviour.
immich_microservices       | [AVHWDeviceContext @ 0x27fce180200] Initialize MFX session: API version is 1.35, implementation version is 1.255
immich_microservices       | Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'upload/library/sven/2022/2022-02/IMG_0746.MOV':
immich_microservices       |   Metadata:
immich_microservices       |     major_brand     : qt  
immich_microservices       |     minor_version   : 0
immich_microservices       |     compatible_brands: qt  
immich_microservices       |     creation_time   : 2022-02-26T09:35:29.000000Z
immich_microservices       |     com.apple.quicktime.location.accuracy.horizontal: 3.535534
immich_microservices       |     com.apple.quicktime.location.ISO6709: +53.0678+007.2713+002.043/
immich_microservices       |     com.apple.quicktime.make: Apple
immich_microservices       |     com.apple.quicktime.model: iPhone 13 Pro
immich_microservices       |     com.apple.quicktime.software: 15.3.1
immich_microservices       |     com.apple.quicktime.creationdate: 2022-02-26T10:35:29+0100
immich_microservices       |   Duration: 00:00:09.62, start: 0.000000, bitrate: 51200 kb/s
immich_microservices       |   Stream #0:0[0x1](und): Video: hevc (Main), 1 reference frame (hvc1 / 0x31637668), yuv420p(tv, bt709, left), 1920x1080 (1920x1088), 50961 kb/s, 239.69 fps, 240 tbr, 2400 tbn (default)
immich_microservices       |     Metadata:
immich_microservices       |       creation_time   : 2022-02-26T09:35:29.000000Z
immich_microservices       |       handler_name    : Core Media Video
immich_microservices       |       vendor_id       : [0][0][0][0]
immich_microservices       |       encoder         : HEVC
immich_microservices       |     Side data:
immich_microservices       |       displaymatrix: rotation of -90.00 degrees
immich_microservices       |   Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 201 kb/s (default)
immich_microservices       |     Metadata:
immich_microservices       |       creation_time   : 2022-02-26T09:35:29.000000Z
immich_microservices       |       handler_name    : Core Media Audio
immich_microservices       |       vendor_id       : [0][0][0][0]
immich_microservices       | Stream mapping:
immich_microservices       |   Stream #0:0 -> #0:0 (hevc (native) -> h264 (h264_qsv))
immich_microservices       |   Stream #0:1 -> #0:1 (aac (native) -> aac (native))
immich_microservices       | Press [q] to stop, [?] for help
immich_microservices       | [graph_1_in_0_1 @ 0x27fce204980] tb:1/44100 samplefmt:fltp samplerate:44100 chlayout:stereo
immich_microservices       | [graph 0 input from stream 0:0 @ 0x27fce0c4c80] w:1920 h:1080 pixfmt:yuv420p tb:1/2400 fr:240/1 sar:0/1
immich_microservices       | [auto_scale_0 @ 0x27fce203300] w:iw h:ih flags:'' interl:0
immich_microservices       | [transpose @ 0x27fce0c4d80] auto-inserting filter 'auto_scale_0' between the filter 'graph 0 input from stream 0:0' and the filter 'transpose'
immich_microservices       | [auto_scale_0 @ 0x27fce203300] w:1920 h:1080 fmt:yuv420p sar:0/1 -> w:1920 h:1080 fmt:nv12 sar:0/1 flags:0x0
immich_microservices       | [transpose @ 0x27fce0c4d80] w:1920 h:1080 dir:1 -> w:1080 h:1920 rotation:clockwise vflip:0
immich_microservices       | [AVHWDeviceContext @ 0x27fce1835c0] VAAPI driver: Intel iHD driver for Intel(R) Gen Graphics - 23.3.0 (919d398).
immich_microservices       | [AVHWDeviceContext @ 0x27fce1835c0] Driver not found in known nonstandard list, using standard behaviour.
immich_microservices       | [auto_scale_0 @ 0x27fce203300] w:1920 h:1080 fmt:yuv420p sar:0/1 -> w:1920 h:1080 fmt:nv12 sar:0/1 flags:0x0
immich_microservices       |     Last message repeated 2 times
immich_microservices       | [h264_qsv @ 0x27fce221d80] Using input frames context (format qsv) with h264_qsv encoder.
immich_microservices       | [h264_qsv @ 0x27fce221d80] Encoder: input is video memory surface
immich_microservices       | [h264_qsv @ 0x27fce221d80] Using the intelligent constant quality (ICQ) ratecontrol method
immich_microservices       | [h264_qsv @ 0x27fce221d80] MFMode:2
immich_microservices       | [h264_qsv @ 0x27fce221d80] Current frame rate is unsupported
immich_microservices       | [h264_qsv @ 0x27fce221d80] some encoding parameters are not supported by the QSV runtime. Please double check the input parameters.
immich_microservices       | Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
immich_microservices       | [AVIOContext @ 0x27fce216800] Statistics: 0 bytes written, 0 seeks, 0 writeouts
immich_microservices       | [aac @ 0x27fce223580] Qavg: 2727.640
immich_microservices       | [aac @ 0x27fce223580] 2 frames left in the queue on closing
immich_microservices       | [AVIOContext @ 0x27fce215cc0] Statistics: 859932 bytes read, 8 seeks
immich_microservices       | Conversion failed!
immich_microservices       | 
immich_microservices       | [Nest] 6  - 08/07/2023, 6:15:26 PM   ERROR [MediaService] Error: ffmpeg exited with code 1: Conversion failed!
immich_microservices       | 
immich_microservices       | [Nest] 6  - 08/07/2023, 6:15:26 PM   ERROR [MediaService] Error occurred during transcoding. Retrying with QSV acceleration disabled.
immich_typesense           | I20230807 18:15:33.594012   358 raft_server.cpp:546] Term: 90, last_index index: 43729, committed_index: 43729, known_applied_index: 43729, applying_index: 0, queued_writes: 0, pending_queue_size: 0, local_sequence: 1350975
immich_typesense           | I20230807 18:15:33.594066   466 raft_server.h:60] Peer refresh succeeded!
immich_typesense           | I20230807 18:15:43.596285   358 raft_server.cpp:546] Term: 90, last_index index: 43729, committed_index: 43729, known_applied_index: 43729, applying_index: 0, queued_writes: 0, pending_queue_size: 0, local_sequence: 1350975
immich_typesense           | I20230807 18:15:43.596344   469 raft_server.h:60] Peer refresh succeeded!
immich_microservices       | [Nest] 6  - 08/07/2023, 6:15:49 PM     LOG [MediaService] Encoding success 9010e3ec-dcbc-4ca3-8b5b-7447cf7639f5
nyanmisaka commented 11 months ago

1920x1080 (1920x1088), 50961 kb/s, 239.69 fps

I suspect that the QSV runtime may not support that frame rate.

immich_microservices       | [h264_qsv @ 0x27fce221d80] Current frame rate is unsupported