我正在嘗試使用此命令列對文件進行編碼:
ffmpeg -i "source.mp4" -c:v libx265 -preset slow -crf 23.8 -vf scale=1920:-1:flags=lanczos -x265-params ref=6:bframes=5:no-sao=1:no-strong-intra-smoothing=1:cutree=0:aq-mode=3:deblock=-1,-1:rskip=0:rc-lookahead=80:subme=1:numa-pools=16:frame-threads=4 -c:a copy -movflags faststart output.mp4
有些文件以非常不同的編碼設定返回。即使 Mediainfo 中的 CRF 也是錯誤的。發生這種情況時我會看到一條警告,內容如下:
[mp4 @ 00000148a5247040] track 1: codec frame size is not set
我用谷歌搜尋了這個,似乎沒有人提到這個警告導致了問題。
我正在使用一個相當新的版本:ffmpeg version 2021-10-03-git-2761a7403b-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
使用 gcc 10.3.0 建置(Rev5,由 MSYS2 專案建置)。
SOURCE MEDIAINFO:
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : [email protected]
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 : 32 min 43 s
Bit rate : 20.5 Mb/s
Width : 3 840 pixels
Height : 2 160 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 25.000 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.099
Stream size : 4.69 GiB (100%)
Writing library : x264 core 157 r2969 d4099dd
Encoding settings : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=12 / 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=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=50 / keyint_min=5 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=25.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : English
Codec configuration box : avcC
X265 OUTPUT MEDIAINFO:
Video
ID : 1
Format : HEVC
Format/Info : High Efficiency Video Coding
Format profile : Main@L4@Main
Codec ID : hev1
Codec ID/Info : High Efficiency Video Coding
Duration : 32 min 43 s
Bit rate : 5 186 kb/s
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 25.000 FPS
Color space : YUV
Chroma subsampling : 4:2:0 (Type 0)
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.100
Stream size : 1.19 GiB (100%)
Encoding settings : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=12 / 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=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=50 / keyint_min=5 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=25.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : English
Color range : Limited
Codec configuration box : hvcC
輸出編碼設定似乎與來源匹配,而不是我的編碼器設定。有些檔案使用完全相同的設定進行良好編碼,但沒有警告訊息「編解碼器幀大小未設定」。我已經更改了很多次設置,但問題文件的結果相同。如果它只發生一次,我會認為來源有問題,但它發生在我編碼的最後 4 個文件中的 2 個上,所以我一定遺漏了一些東西。輸出中可能只是不正確的元數據,但我不確定。這在 Handbrake 中沒有發生,我嘗試了 FFMPEG 的不同版本,遇到相同的問題。