如何使用 FFmpeg 和 GeForce 硬件将 4K MKV 电影解码和编码为 1080p

How to use FFmpeg and GeForce Hardware to decode and encode 4K MKV movie to 1080p

我正在努力按照提供的将 4k 电影转换为 1080p 的说明进行操作,这样我就可以 运行 在我的 plex 服务器上更轻松地进行转换。

我有一个 Geforce 1080Ti,并且在构建 ffmpeg 时启用了 cuda 和所有必要的选项。

我一直收到一个奇怪的错误,我卡在了下面的点上。

这是我目前正在处理的代码

REM @ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
COLOR 0A
TITLE CONVERT 4K TO 1080P USING GEFORCE HW

PUSHD "%~dp0"

SET "FF=C:\MAB\local64\bin-video\ffmpeg.exe"

FOR /R %%G IN (*.mkv) DO (
    "%FF%" -hide_banner -hwaccel cuda -y -i "%%~dpnG.mkv" -c:v h264_nvenc -preset slow -pix_fmts yuv420p10le -vf scale='1920:-1' -c:a copy "%%~dpnG(1080p).mkv"
    )

ECHO.
PAUSE
EXIT

下面是我在运行执行上述命令

时得到的错误输出
Guessed Channel Layout for Input Stream #0.1 : 5.1
Input #0, matroska,webm, from 'Mulan_2020.mkv':
  Metadata:
    title           : mandtv.net
    encoder         : libebml v1.4.0 + libmatroska v1.6.2
    creation_time   : 2020-09-10T05:08:02.000000Z
  Duration: 01:55:08.70, start: 0.000000, bitrate: 16704 kb/s
    Stream #0:0(eng): Video: hevc (Main 10), yuv420p10le(tv, bt2020nc/bt2020/smpte2084), 3840x1608 [SAR 1:1 DAR 160:67], 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default)
    Metadata:
      BPS-eng         : 15933746
      DURATION-eng    : 01:55:08.652000000
      NUMBER_OF_FRAMES-eng: 165642
      NUMBER_OF_BYTES-eng: 13760089087
      _STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:1(eng): Audio: eac3, 48000 Hz, 5.1, fltp (default) (forced)
    Metadata:
      title           : En
      BPS-eng         : 768000
      DURATION-eng    : 01:55:08.704000000
      NUMBER_OF_FRAMES-eng: 215897
      NUMBER_OF_BYTES-eng: 663235584
      _STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:2(eng): Subtitle: subrip
    Metadata:
      title           : English
      BPS-eng         : 35
      DURATION-eng    : 01:50:28.504000000
      NUMBER_OF_FRAMES-eng: 1150
      NUMBER_OF_BYTES-eng: 29135
      _STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:3(ger): Subtitle: subrip
    Metadata:
      title           : de
      BPS-eng         : 2
      DURATION-eng    : 00:03:07.062000000
      NUMBER_OF_FRAMES-eng: 2
      NUMBER_OF_BYTES-eng: 53
      _STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:4(ger): Subtitle: subrip
    Metadata:
      title           : de
      BPS-eng         : 27
      DURATION-eng    : 01:54:16.482000000
      NUMBER_OF_FRAMES-eng: 933
      NUMBER_OF_BYTES-eng: 23256
      _STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:5(fre): Subtitle: subrip
    Metadata:
      title           : fr
      BPS-eng         : 0
      DURATION-eng    : 01:40:51.510000000
      NUMBER_OF_FRAMES-eng: 21
      NUMBER_OF_BYTES-eng: 380
      _STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:6(fre): Subtitle: subrip
    Metadata:
      title           : fr
      BPS-eng         : 29
      DURATION-eng    : 01:54:19.902000000
      NUMBER_OF_FRAMES-eng: 806
      NUMBER_OF_BYTES-eng: 25098
      _STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:7(spa): Subtitle: subrip
    Metadata:
      title           : es
      BPS-eng         : 2
      DURATION-eng    : 00:03:21.201000000
      NUMBER_OF_FRAMES-eng: 3
      NUMBER_OF_BYTES-eng: 73
      _STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:8(spa): Subtitle: subrip
    Metadata:
      title           : es
      BPS-eng         : 30
      DURATION-eng    : 01:43:53.693000000
      NUMBER_OF_FRAMES-eng: 783
      NUMBER_OF_BYTES-eng: 24134
      _STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:9(ita): Subtitle: subrip
    Metadata:
      title           : it
      BPS-eng         : 2
      DURATION-eng    : 00:03:08.522000000
      NUMBER_OF_FRAMES-eng: 2
      NUMBER_OF_BYTES-eng: 67
      _STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:10(ita): Subtitle: subrip
    Metadata:
      title           : it
      BPS-eng         : 27
      DURATION-eng    : 01:54:16.649000000
      NUMBER_OF_FRAMES-eng: 784
      NUMBER_OF_BYTES-eng: 23506
      _STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:11(por): Subtitle: subrip
    Metadata:
      title           : pt
      BPS-eng         : 27
      DURATION-eng    : 01:54:16.649000000
      NUMBER_OF_FRAMES-eng: 784
      NUMBER_OF_BYTES-eng: 23202
      _STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:12(por): Subtitle: subrip
    Metadata:
      title           : pt
      BPS-eng         : 2
      DURATION-eng    : 00:03:08.522000000
      NUMBER_OF_FRAMES-eng: 2
      NUMBER_OF_BYTES-eng: 61
      _STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:13(rus): Subtitle: subrip (default)
    Metadata:
      title           : ru
      BPS-eng         : 0
      DURATION-eng    : 01:37:43.480000000
      NUMBER_OF_FRAMES-eng: 9
      NUMBER_OF_BYTES-eng: 420
      _STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:14(rus): Subtitle: subrip
    Metadata:
      title           : ru
      BPS-eng         : 50
      DURATION-eng    : 01:44:17.000000000
      NUMBER_OF_FRAMES-eng: 850
      NUMBER_OF_BYTES-eng: 39721
      _STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:15(ukr): Subtitle: subrip
    Metadata:
      title           : uk
      BPS-eng         : 50
      DURATION-eng    : 01:43:53.650000000
      NUMBER_OF_FRAMES-eng: 848
      NUMBER_OF_BYTES-eng: 39165
      _STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (native) -> h264 (h264_nvenc))
  Stream #0:1 -> #0:1 (copy)
  Stream #0:2 -> #0:2 (subrip (srt) -> ass (ssa))
Press [q] to stop, [?] for help
[h264_nvenc @ 000002306685ccc0] 10 bit encode not supported
[h264_nvenc @ 000002306685ccc0] Provided device doesn't support required NVENC features
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
Conversion failed!

谁能看出我遗漏了什么?

@ECHO OFF
SETLOCAL
COLOR 0A
TITLE CONVERT 4K TO 1080P WITH GEFORCE HW ACCELERATION

:---------------------------------------------------------------------------------

REM CHANGE WORKING DIRECTORY TO THE SCRIPT'S DIRECTORY
PUSHD "%~dp0"

:---------------------------------------------------------------------------------

REM MAXIMIZE CMD WINDOW
IF NOT "%1"=="MAX" START /MAX CMD /D /C %0 MAX & EXIT /B

:---------------------------------------------------------------------------------

REM POINT FF VAR TO FFMPEG.EXE'S FULL PATH
SET "FF=C:\MAB\local64\bin-video\ffmpeg.exe"

REM RECURSIVELY SEARCH FOR VIDEO IN THE WORKING DIRECTORY
FOR /R %%G IN (*.mkv) DO (
    "%FF%" -hide_banner -hwaccel cuda -y -i "%%~dpnG.mkv" -c:v nvenc_hevc -preset p7 -tune hq -vf scale='1920:-1' -c:a copy "%%~dpnG(1080p).mkv"
    )

:---------------------------------------------------------------------------------

REM CHANGE THE COLOR OF THE CMD WINDOW WHEN FFMPEG HAS FINISHED
COLOR 0E
ECHO=
ECHO FFMPEG HAS FINISHED & ECHO=
PAUSE