ffmpeg DVD 转换质量一般

ffmpeg DVD 转换质量一般

我正在尝试将我拥有的 DVD 转换为 mp4/lib265 格式。为了测试质量,我只转换了输入视频的前两分钟(这是一个连接的 vob 文件)。源视频的分辨率不是特别高,因为是 DVD720x480

  • 我试过 8/10/12 位 hevc
  • 对于 720p 视频,我通常使用 crf-22,对于 1080p 视频,我通常使用 crf-20,并且通常对这些值感到满意。这张 DVD 的分辨率低于这个值,我尝试过将分辨率调低至 crf-18
  • 我总是使用min-keyintkeyint参数,因为我将它们保持在非常低的水平以提高搜索性能。这些足够低的水平应该不会降低质量,但min-keyint为了以防万一,我尝试使用更低的参数。

问题:在视频中,每当摄像机移动时,我都能在屏幕上看到所有细节的巨大像素。摄像机移动甚至不是特别快。例如,它从主角的腰带高度移动到面部大约需要 2 秒。

问题: 有人可以指出我做错了什么或者还可以做什么来解决这个问题。或者可能是一些微调参数?

运行测试的命令:

ffmpeg ^
-i "ConCat2.vob" ^
-ss 00:00:00 -to 00:02:00 -c:v libx265 -c:a aac -x265-params  "crf=20:min-keyint=5:keyint=50"  -preset slow -map 0:1 -map 0:2 "08 bit.crf20.ki05.mp4"  ^
-ss 00:00:00 -to 00:02:00 -c:v libx265 -c:a aac -x265-params  "crf=20:min-keyint=5:keyint=50"  -preset slow -pix_fmt yuv420p10le -map 0:1 -map 0:2 "10 bit.crf20.ki05.mp4" ^
-ss 00:00:00 -to 00:02:00 -c:v libx265 -c:a aac -x265-params  "crf=20:min-keyint=5:keyint=50"  -preset slow -pix_fmt yuv420p12le -map 0:1 -map 0:2 "12 bit.crf20.ki05.mp4" ^
-ss 00:00:00 -to 00:02:00 -c:v libx265 -c:a aac -x265-params  "crf=20:min-keyint=25:keyint=50" -preset slow -map 0:1 -map 0:2 "08 bit.crf20.ki25.mp4" ^
-ss 00:00:00 -to 00:02:00 -c:v libx265 -c:a aac -x265-params  "crf=20:min-keyint=25:keyint=50" -preset slow -pix_fmt yuv420p10le -map 0:1 -map 0:2 "10 bit.crf20.ki25.mp4" ^
-ss 00:00:00 -to 00:02:00 -c:v libx265 -c:a aac -x265-params  "crf=20:min-keyint=25:keyint=50" -preset slow -pix_fmt yuv420p12le -map 0:1 -map 0:2 "12 bit.crf20.ki25.mp4" ^
-ss 00:00:00 -to 00:02:00 -c:v libx265 -c:a aac -x265-params  "crf=18:min-keyint=25:keyint=50" -preset slow -map 0:1 -map 0:2 "08 bit.crf18.ki25.mp4" ^
-ss 00:00:00 -to 00:02:00 -c:v libx265 -c:a aac -x265-params  "crf=18:min-keyint=25:keyint=50" -preset slow -pix_fmt yuv420p10le -map 0:1 -map 0:2 "10 bit.crf18.ki25.mp4" ^
-ss 00:00:00 -to 00:02:00 -c:v libx265 -c:a aac -x265-params  "crf=18:min-keyint=25:keyint=50" -preset slow -pix_fmt yuv420p12le -map 0:1 -map 0:2 "12 bit.crf18.ki25.mp4"

ffprobe 输入:

ffprobe version 4.3.1-2020-10-01-full_build-www.gyan.dev Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 10.2.0 (Rev3, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Input #0, mpeg, from 'ConCat2.vob':
  Duration: 01:26:30.42, start: 0.300300, bitrate: 5891 kb/s
    Stream #0:0[0x1bf]: Data: dvd_nav_packet
    Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, smpte170m, bottom first), 720x480 [SAR 8:9 DAR 4:3], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Side data:
      cpb: bitrate max/min/avg: 7500000/0/0 buffer size: 1835008 vbv_delay: N/A
    Stream #0:2[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s

ffmpeg编码结果摘要屏幕:

x265 [info]: frame I:     74, Avg QP:19.75  kb/s: 15050.33
x265 [info]: frame P:    902, Avg QP:21.58  kb/s: 12471.95
x265 [info]: frame B:   2621, Avg QP:26.88  kb/s: 3518.91
x265 [info]: Weighted P-Frames: Y:6.5% UV:5.9%
x265 [info]: consecutive B-frames: 3.7% 2.2% 39.7% 30.9% 23.6%

encoded 3597 frames in 3196.04s (1.13 fps), 6001.25 kb/s, Avg QP:25.41
[aac @ 000001a27fe3ccc0] Qavg: 314.316

x265 [info]: frame I:     74, Avg QP:19.78  kb/s: 15170.72
x265 [info]: frame P:    890, Avg QP:21.60  kb/s: 12635.53
x265 [info]: frame B:   2633, Avg QP:26.82  kb/s: 3698.17
x265 [info]: Weighted P-Frames: Y:8.4% UV:7.6%
x265 [info]: consecutive B-frames: 3.7% 2.4% 35.9% 33.0% 25.0%

encoded 3597 frames in 3196.02s (1.13 fps), 6145.55 kb/s, Avg QP:25.38
[aac @ 000001a200728f80] Qavg: 314.316

x265 [info]: frame I:     74, Avg QP:20.40  kb/s: 14358.58
x265 [info]: frame P:    813, Avg QP:22.09  kb/s: 12347.13
x265 [info]: frame B:   2710, Avg QP:26.81  kb/s: 3986.21
x265 [info]: Weighted P-Frames: Y:14.5% UV:13.0%
x265 [info]: consecutive B-frames: 1.1% 1.9% 20.0% 44.3% 32.7%

encoded 3597 frames in 3196.01s (1.13 fps), 6089.35 kb/s, Avg QP:25.61
[aac @ 000001a20072b880] Qavg: 314.316

x265 [info]: frame I:     74, Avg QP:19.78  kb/s: 15063.06
x265 [info]: frame P:    903, Avg QP:21.57  kb/s: 12490.80
x265 [info]: frame B:   2620, Avg QP:26.88  kb/s: 3506.11
x265 [info]: Weighted P-Frames: Y:6.4% UV:5.6%
x265 [info]: consecutive B-frames: 2.9% 2.6% 40.9% 30.8% 22.8%

encoded 3597 frames in 3196.01s (1.13 fps), 5999.41 kb/s, Avg QP:25.40
[aac @ 000001a2005343c0] Qavg: 314.316

x265 [info]: frame I:     74, Avg QP:19.81  kb/s: 15185.65
x265 [info]: frame P:    888, Avg QP:21.59  kb/s: 12655.86
x265 [info]: frame B:   2635, Avg QP:26.82  kb/s: 3687.45
x265 [info]: Weighted P-Frames: Y:8.8% UV:7.8%
x265 [info]: consecutive B-frames: 2.7% 2.4% 37.5% 33.1% 24.3%

encoded 3597 frames in 3196.01s (1.13 fps), 6138.05 kb/s, Avg QP:25.39
[aac @ 000001a200537a80] Qavg: 314.316

x265 [info]: frame I:     74, Avg QP:20.41  kb/s: 14386.07
x265 [info]: frame P:    815, Avg QP:22.09  kb/s: 12322.46
x265 [info]: frame B:   2708, Avg QP:26.80  kb/s: 3988.57
x265 [info]: Weighted P-Frames: Y:14.7% UV:13.1%
x265 [info]: consecutive B-frames: 0.9% 1.2% 20.8% 46.5% 30.6%

encoded 3597 frames in 3196.02s (1.13 fps), 6090.74 kb/s, Avg QP:25.60
[aac @ 000001a200538cc0] Qavg: 314.316

x265 [info]: frame I:     74, Avg QP:17.78  kb/s: 17517.32
x265 [info]: frame P:    903, Avg QP:19.57  kb/s: 15024.90
x265 [info]: frame B:   2620, Avg QP:24.80  kb/s: 4860.86
x265 [info]: Weighted P-Frames: Y:6.4% UV:5.6%
x265 [info]: consecutive B-frames: 2.9% 2.6% 40.9% 30.8% 22.8%

encoded 3597 frames in 3196.02s (1.13 fps), 7672.84 kb/s, Avg QP:23.34
[aac @ 000001a2005363c0] Qavg: 314.316

x265 [info]: frame I:     74, Avg QP:17.81  kb/s: 17620.88
x265 [info]: frame P:    888, Avg QP:19.59  kb/s: 15156.42
x265 [info]: frame B:   2635, Avg QP:24.74  kb/s: 5070.71
x265 [info]: Weighted P-Frames: Y:8.8% UV:7.8%
x265 [info]: consecutive B-frames: 2.7% 2.4% 37.5% 33.1% 24.3%

encoded 3597 frames in 3196.02s (1.13 fps), 7818.79 kb/s, Avg QP:23.33
[aac @ 000001a20053b5c0] Qavg: 314.316

x265 [info]: frame I:     74, Avg QP:18.41  kb/s: 16755.65
x265 [info]: frame P:    815, Avg QP:20.09  kb/s: 14822.84
x265 [info]: frame B:   2708, Avg QP:24.71  kb/s: 5464.50
x265 [info]: Weighted P-Frames: Y:14.7% UV:13.1%
x265 [info]: consecutive B-frames: 0.9% 1.2% 20.8% 46.5% 30.6%

encoded 3597 frames in 3196.02s (1.13 fps), 7817.18 kb/s, Avg QP:23.53
[aac @ 000001a2006cb940] Qavg: 314.316

答案1

在真正找到针对我的特定问题的答案之前,我尝试了几种方法,并把它们写在这里,希望其中一些可能会对其他人有所帮助。

  • 尝试使用“no-sao=1”禁用 sao,但无改善。
  • 玩过psy-rdrdoq并且psy-rdoq参数值非常高和非常低,没有显着的改进
  • 减少ctuctu=16没有任何改善。
  • 许多人认为 h265 更适合高分辨率视频,而不是旧的低分辨率视频。我尝试切换到 h264,没有显著变化(文件大小除外!)
  • 这时我放弃了,最后一次尝试,我删除了所有参数,并用 h265 编码,只是为了CRF=1 -preset slower看看会发生什么。这产生了预期的巨大文件,花了很长时间,但仍然产生了相同的结果。
  • 我跳到 Handbrake 并使用默认设置进行了 h264 编码,我注意到问题已经消失(尽管使用相同的底层库)
  • 使用 handbrake 的 h265 默认设置,尽管使用相同的底层库,问题再次消失。
  • 比较了 handbrake 和 ffmpeg 的调试输出,我注意到唯一显著的区别是 handbrake 正在应用decomb一个去隔行过滤器。
  • 我目前的 ffmpeg 中没有编译 decomb,但我尝试了yadif一下-vf yadif,然后问题消失了!问题出在隔行视频上。我还尝试了一些其他的反隔行算法,比如bwdif和,nnedi它们都解决了这个问题。nnedi产生了最好的结果,但也花费了更长的时间。
  • 最后我重新添加了其他选项,问题仍然得到解决。作为参考,我用来将此特定 DVD 转换为 h265 的最终命令如下:
ffmpeg ^
-i "ConCat2.vob" ^
-ss 00:00:00 -to 00:02:00 -c:v libx265 -c:a aac -vf yadif -x265-params  "crf=22:min-keyint=25:keyint=50" -preset slow -map 0:1 -map 0:2 "08 bit.crf22.yadif.mp4"

相关内容