mdhiggins / sickbeard_mp4_automator

Automatically convert video files to a standardized format with metadata tagging to create a beautiful and uniform media library
MIT License
1.5k stars 206 forks source link

Intel hardware acceleration fails with max-width defined #1688

Closed jakanaka closed 7 months ago

jakanaka commented 8 months ago

Describe the bug QSV Hardware acceleration is not working if i define max-width = 1250 , it works it i leave it as 0

Command or context you are trying to run python3 manual.py -i 'Skanda (2023) - 720p.mkv'

autoProcess.ini settings


[Converter]
ffmpeg = /usr/lib/jellyfin-ffmpeg/ffmpeg
ffprobe = /usr/lib/jellyfin-ffmpeg/ffprobe
threads = 0
hwaccels =
hwaccel-decoders = h264_qsv
hwdevices =
hwaccel-output-format = qsv:qsv
output-directory =
output-directory-space-ratio = 0.0
output-format = mp4
output-extension = mp4
temp-extension = tmp
minimum-size = 0
ignored-extensions = nfo, ds_store
copy-to =
move-to =
delete-original = True
process-same-extensions = True
bypass-if-copying-all = False
force-convert = False
post-process = False
wait-post-process = False
detailed-progress = False
opts-separator = ,
preopts =
postopts =
regex-directory-replace = [^\w\-_\. ]

[Permissions]
chmod = 0644
uid = -1
gid = -1

[Metadata]
relocate-moov = False
full-path-guess = False
tag = False
tag-language = eng
download-artwork = poster
sanitize-disposition =
strip-metadata = False
keep-titles = False

[Video]
codec = h264qsv, x264, h264
max-bitrate = 1250
bitrate-ratio =
crf = -1
crf-profiles =
preset = slow
codec-parameters =
dynamic-parameters = False
max-width = 1280
profile = high
max-level = 0.0
pix-fmt =
prioritize-source-pix-fmt = True
filter =
force-filter = False

[HDR]
codec =
pix-fmt =
space = bt2020nc
transfer = smpte2084
primaries = bt2020
preset = high
codec-parameters =
filter =
force-filter = False
profile =

[Audio]
codec = aac
languages = eng
default-language = eng
include-original-language = True
first-stream-of-language = True
channel-bitrate = 128
variable-bitrate = 0
max-bitrate = 160
max-channels = 2
filter =
profile =
force-filter = False
sample-rates =
sample-format =
copy-original = False
aac-adtstoasc = False
ignored-dispositions =
force-default = True
unique-dispositions = False
stream-codec-combinations =

[Audio.Sorting]
sorting = language, channels.d, map, d.comment
default-sorting = channels.d, map, d.comment
codecs =

[Universal Audio]
codec =
channel-bitrate = 196
variable-bitrate = 0
first-stream-only = True
filter =
profile =
force-filter = False

[Audio.ChannelFilters]

[Subtitle]
codec = mov_text
codec-image-based =
languages = eng
default-language = eng
include-original-language = False
first-stream-of-language = False
encoding =
burn-subtitles = False
burn-dispositions =
embed-subs = True
embed-image-subs = False
embed-only-internal-subs = False
filename-dispositions = forced
ignore-embedded-subs = False
ignored-dispositions =
force-default = False
unique-dispositions = False
attachment-codec =
remove-bitstream-subs = False

[Subtitle.Sorting]
sorting = language, d.comment, d.default.d, d.forced.d
codecs =
burn-sorting = language, d.comment, d.default.d, d.forced.d

[Subtitle.CleanIt]
enabled = False
config-path =
tags =

[Subtitle.FFSubsync]
enabled = True

[Subtitle.Subliminal]
download-subs = True
download-forced-subs = False
include-hearing-impaired-subs = False
providers =

[Subtitle.Subliminal.Auth]
opensubtitles = <>

[Sonarr]
host = 127.0.0.1
port = <>
apikey = <>
ssl = False
webroot = <>
force-rename = False
rescan = True
block-reprocess = True
in-progress-check = True

[Radarr]
host = 127.0.0.1
port = <>
apikey = <>
ssl = False
webroot = <>
force-rename = False
rescan = True
block-reprocess = True
in-progress-check = True

[Sickbeard]
host = localhost
port = 8081
ssl = False
apikey =
webroot =
username =
password =

[Sickrage]
host = localhost
port = 8081
ssl = False
apikey =
webroot =
username =
password =

[SABNZBD]
convert = True
sickbeard-category = sickbeard
sickrage-category = sickrage
sonarr-category = sonarr
radarr-category = radarr
bypass-category = bypass
output-directory =
path-mapping =

[Deluge]
sickbeard-label = sickbeard
sickrage-label = sickrage
sonarr-label = sonarr
radarr-label = radarr
bypass-label = bypass
convert = True
host = localhost
port = 58846
username =
password =
output-directory =
remove = False
path-mapping =

[qBittorrent]
sickbeard-label = sickbeard
sickrage-label = sickrage
sonarr-label = sonarr
radarr-label = radarr
bypass-label = bypass
convert = True
action-before =
action-after =
host = localhost
port = 8080
ssl = False
username =
password =
output-directory =
path-mapping =

[uTorrent]
sickbeard-label = sickbeard
sickrage-label = sickrage
sonarr-label = sonarr
radarr-label = radarr
bypass-label = bypass
convert = True
webui = False
action-before =
action-after =
host = localhost
ssl = False
port = 8080
username =
password =
output-directory =
path-mapping =

[Plex]
host = localhost
port = 32400
refresh = False
token =
username =
password =
servername =
ssl = True
ignore-certs = False
path-mapping =

Log files


Manual processor started.
Python 64-bit 3.8.16 (default, Dec  7 2022, 01:12:13)
[GCC 7.5.0].
Guessit version: 3.7.1.
/usr/bin/python3
Loading config file /root/sickbeard_mp4_automator/config/autoProcess.ini.
Processing file /home/user/movies/Bollywood/Skanda (2023)/Skanda (2023) - 720p.mkv
Input Data
{
    "format": "matroska,webm",
    "format-fullname": "Matroska / WebM",
    "video": {
        "index": 0,
        "codec": "h264",
        "bitrate": 3284977,
        "pix_fmt": "yuv420p",
        "profile": "high",
        "fps": 24.0,
        "framedata": {
            "pix_fmt": "yuv420p",
            "color_space": "bt709",
            "color_primaries": "bt709",
            "color_transfer": "bt709",
            "side_data_list": [
                {
                    "side_data_type": "H.26[45] User Data Unregistered SEI message"
                }
            ]
        },
        "dimensions": "1920x1080",
        "level": 4.0,
        "field_order": "progressive"
    },
    "audio": [
        {
            "index": 1,
            "codec": "eac3",
            "bitrate": 192000,
            "channels": 6,
            "samplerate": 48000,
            "language": "tel",
            "disposition": "+default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions"
        }
    ],
    "subtitle": [
        {
            "index": 2,
            "codec": "subrip",
            "disposition": "+default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "eng"
        }
    ],
    "attachment": []
}
Reading video stream.
Video codec detected: h264.
Pix Fmt: yuv420p.
Profile: high.
Video codec parameters None.
Creating h264qsv video stream from source stream 0.
Reading audio streams.
The following stream indexes have been identified as being copies: [] [stream-codec-combinations].
Audio detected for stream 1 - eac3 tel 6 channel.
Creating aac audio stream from source stream 1.
Found 0 streams that can be removed from the output file since they will be duplicates [stream-codec-combinations].
Final sorting:
['0->0']
Final sorting:
['0->0']
Default audio stream set to tel aac 2 channel stream [audio-default-sorting: ['channels.d', 'map', 'd.comment']].
Reading subtitle streams.
Subtitle detected for stream 2 - subrip eng.

Stream 2 is text-based subtitle for codec subrip.
Creating mov_text subtitle stream from source stream 2.
Scanned for external subtitles and found 0 results in your approved languages.
Final sorting:
['0->0']
h264_qsv decoder is supported by this ffmpeg build and will also be used [hwaccel-decoders].
Output Data
{
    "source": [
        "/home/user/movies/Bollywood/Skanda (2023)/Skanda (2023) - 720p.mkv"
    ],
    "format": "mp4",
    "video": {
        "codec": "h264qsv",
        "map": 0,
        "bitrate": 1250,
        "crf": -1,
        "maxrate": null,
        "bufsize": null,
        "level": 0.0,
        "profile": "high",
        "preset": "slow",
        "pix_fmt": null,
        "field_order": "progressive",
        "width": 1280,
        "filter": null,
        "params": null,
        "framedata": null,
        "bsf": null,
        "debug": "video.max-bitrate.max-width",
        "title": "HD"
    },
    "audio": [
        {
            "map": 1,
            "codec": "aac",
            "channels": 2,
            "bitrate": 160,
            "profile": null,
            "quality": 0,
            "filter": null,
            "samplerate": null,
            "sampleformat": "",
            "language": "tel",
            "disposition": "+default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "bsf": null,
            "debug": "audio.max-channels",
            "title": "Stereo"
        }
    ],
    "subtitle": [
        {
            "map": 2,
            "codec": "mov_text",
            "language": "eng",
            "disposition": "+default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "debug": "subtitle.embed-subs",
            "title": null
        }
    ],
    "attachment": []
}
Preopts
[
    "-fix_sub_duration",
    "-vcodec",
    "h264_qsv"
]
Postopts
[
    "-threads",
    "0",
    "-metadata:g",
    "encoding_tool=SMA"
]
Downloaded Subtitles
[]
Starting conversion.

FFmpeg command:
======================
/usr/lib/jellyfin-ffmpeg/ffmpeg -fix_sub_duration -vcodec h264_qsv -i "/home/user/movies/Bollywood/Skanda (2023)/Skanda (2023) - 720p.mkv" -vcodec h264_qsv -map 0:0 -field_order progressive -vb 1250k -metadata:s:v BPS=1250000 -metadata:s:v BPS-eng=1250000 -metadata:s:v title=HD -metadata:s:v handler_name=HD -preset slow -profile:v high -vf scale_qsv=1280:720 -tag:v avc1 -look_ahead 0 -c:a:0 aac -map 0:1 -ac:a:0 2 -b:a:0 160k -metadata:s:a:0 BPS=160000 -metadata:s:a:0 BPS-eng=160000 -metadata:s:a:0 title=Stereo -metadata:s:a:0 handler_name=Stereo -metadata:s:a:0 language=tel -disposition:a:0 +default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions -strict experimental -c:s:0 mov_text -map 0:2 -metadata:s:s:0 title= -metadata:s:s:0 handler_name= -metadata:s:s:0 language=eng -disposition:s:0 +default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions -f mp4 -threads 0 -metadata:g encoding_tool=SMA -y "/home/user/movies/Bollywood/Skanda (2023)/Skanda (2023) - 720p.tmp"
======================
[                    ] 0% Error converting file, FFMPEG error.
Traceback (most recent call last):
  File "/root/sickbeard_mp4_automator/resources/mediaprocessor.py", line 2315, in convert
    for timecode, debug in conv:
  File "/root/sickbeard_mp4_automator/converter/__init__.py", line 329, in convert
    for timecode, debug in self.ffmpeg.convert(outfile,
  File "/root/sickbeard_mp4_automator/converter/ffmpeg.py", line 798, in convert
    raise FFMpegConvertError('Exited with code %d' % p.returncode, cmd,
converter.ffmpeg.FFMpegConvertError: <unprintable FFMpegConvertError object>
/usr/lib/jellyfin-ffmpeg/ffmpeg -fix_sub_duration -vcodec h264_qsv -i /home/user/movies/Bollywood/Skanda (2023)/Skanda (2023) - 720p.mkv -vcodec h264_qsv -map 0:0 -field_order progressive -vb 1250k -metadata:s:v BPS=1250000 -metadata:s:v BPS-eng=1250000 -metadata:s:v title=HD -metadata:s:v handler_name=HD -preset slow -profile:v high -vf scale_qsv=1280:720 -tag:v avc1 -look_ahead 0 -c:a:0 aac -map 0:1 -ac:a:0 2 -b:a:0 160k -metadata:s:a:0 BPS=160000 -metadata:s:a:0 BPS-eng=160000 -metadata:s:a:0 title=Stereo -metadata:s:a:0 handler_name=Stereo -metadata:s:a:0 language=tel -disposition:a:0 +default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions -strict experimental -c:s:0 mov_text -map 0:2 -metadata:s:s:0 title= -metadata:s:s:0 handler_name= -metadata:s:s:0 language=eng -disposition:s:0 +default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions -f mp4 -threads 0 -metadata:g encoding_tool=SMA -y /home/user/movies/Bollywood/Skanda (2023)/Skanda (2023) - 720p.tmp
ffmpeg version 5.1.3-Jellyfin Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
  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, matroska,webm, from '/home/user/movies/Bollywood/Skanda (2023)/Skanda (2023) - 720p.mkv':
  Metadata:
    encoder         : libebml v1.4.4 + libmatroska v1.7.1
    creation_time   : 2023-11-01T19:35:35.000000Z
    MOVIE/ENCODER   : Lavf58.20.100
  Duration: 02:44:37.18, start: 0.000000, bitrate: 3478 kb/s
  Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 24 fps, 24 tbr, 1k tbn (default)
    Metadata:
      BPS             : 3284977
      DURATION        : 02:44:37.167000000
      NUMBER_OF_FRAMES: 237052
      NUMBER_OF_BYTES : 4055783906
      _STATISTICS_WRITING_APP: mkvmerge v79.0 ('Funeral Pyres') 64-bit
      _STATISTICS_WRITING_DATE_UTC: 2023-11-01 19:35:35
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
  Stream #0:1(tel): Audio: eac3, 48000 Hz, 5.1(side), fltp, 192 kb/s (default)
    Metadata:
      title           : Telugu
      BPS             : 192000
      DURATION        : 02:44:37.184000000
      NUMBER_OF_FRAMES: 308662
      NUMBER_OF_BYTES : 237052416
      _STATISTICS_WRITING_APP: mkvmerge v79.0 ('Funeral Pyres') 64-bit
      _STATISTICS_WRITING_DATE_UTC: 2023-11-01 19:35:35
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
  Stream #0:2(eng): Subtitle: subrip (default)
    Metadata:
      title           : English
      BPS             : 65
      DURATION        : 02:41:10.125000000
      NUMBER_OF_FRAMES: 1918
      NUMBER_OF_BYTES : 79571
      _STATISTICS_WRITING_APP: mkvmerge v79.0 ('Funeral Pyres') 64-bit
      _STATISTICS_WRITING_DATE_UTC: 2023-11-01 19:35:35
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_qsv) -> h264 (h264_qsv))
  Stream #0:1 -> #0:1 (eac3 (native) -> aac (native))
  Stream #0:2 -> #0:2 (subrip (srt) -> mov_text (native))
Press [q] to stop, [?] for help
[Parsed_scale_qsv_0 @ 0x55dc0c773300] The QSV VPP Scale option is not supported with this MSDK version.
[Parsed_scale_qsv_0 @ 0x55dc0c773300] No hw context provided.
[Parsed_scale_qsv_0 @ 0x55dc0c773300] Failed to configure output pad on Parsed_scale_qsv_0
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:0
[aac @ 0x55dc0c6614c0] Qavg: 137.846
[aac @ 0x55dc0c6614c0] 2 frames left in the queue on closing
Conversion failed!

/home/user/movies/Bollywood/Skanda (2023)/Skanda (2023) - 720p.tmp deleted.
There was an error processing file /home/user/movies/Bollywood/Skanda (2023)/Skanda (2023) - 720p.mkv, no output data received

FFMpeg headers

ffmpeg version 5.1.3-Jellyfin Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
  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
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

System Information

Expected behavior A clear and concise description of what you expected to happen.

Additional context Add any other context about the problem here.

Issues posted without any logs or autoProcess settings will be closed

mdhiggins commented 8 months ago

[Parsed_scale_qsv_0 @ 0x55dc0c773300] The QSV VPP Scale option is not supported with this MSDK version.

FFMPEG bug

https://community.intel.com/t5/Graphics/ffmpeg-5-0-breaks-QSV-syntax-for-hardware-aceceleration/td-p/1368941

https://ffmpeg.org/pipermail/ffmpeg-devel/2022-January/290767.html

mdhiggins commented 8 months ago

If you can produce a version of the command that works with the scale_qsv filter that does work please share

jakanaka commented 8 months ago

If you can produce a version of the command that works with the scale_qsv filter that does work please share

I will try

jakanaka commented 8 months ago

If you can produce a version of the command that works with the scale_qsv filter that does work please share

ffmpeg -hwaccel qsv -i Skanda.mkv -c:v h264_qsv -vf "scale_qsv=1280:720" -c:a copy output_720p.mkv

mdhiggins commented 8 months ago

Hm so the generated command compared to yours is using the same filter, but your generated command lacks the -hwaccel qsv parameter

Add that to your options so it gets included in the command and see if that makes a difference

[Converter]
hwaccels = qsv
mdhiggins commented 8 months ago

Additionally the generated command is adding a parameter to force using the decoder as well, if you still have issues with the above change you could remove that by removing the decoder option

[Converter]
hwaccel-decoders =