我有一个帧速率可变的文件,我想重新编码。到目前为止,我的尝试总是导致帧速率从 23.98 变为 24。我尝试过“-vsync vfr”和“-vsync passthrough”,但无济于事。
输入文件(ffprobe):
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'snippet.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42isomhvc1
creation_time : 2021-05-30T14:23:59.000000Z
Duration: 00:54:23.92, start: 0.000000, bitrate: 11430 kb/s
Stream #0:0(und): Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 9269 kb/s, 23.98 fps, 24 tbr, 12288 tbn, 24 tbc (default)
Metadata:
creation_time : 2021-05-30T14:23:59.000000Z
handler_name : Video Media Handler
encoder : HEVC Coding
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 1081 kb/s (default)
Metadata:
creation_time : 2021-05-30T14:23:59.000000Z
handler_name : Sound Media Handler
Stream #0:2(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 1074 kb/s (default)
Metadata:
creation_time : 2021-05-30T14:23:59.000000Z
handler_name : Sound Media Handler
使用的ffmpeg命令行:
D:\ffmpeg\bin\ffmpeg -analyzeduration 200M -probesize 200M -i snippet.mp4 -vsync vfr -map 0 -c:a copy -c:v libx265 -preset slower -x265-params crf=21 -strict experimental snippet.mkv
ffmpeg 输出的结果:
ffmpeg version 4.3.2-2021-02-27-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10.2.0 (Rev6, 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
[aac @ 0000024232d47480] This stream seems to incorrectly report its last channel as LFE[6], mapping to LFE[0]
[aac @ 0000024232d50d00] This stream seems to incorrectly report its last channel as LFE[6], mapping to LFE[0]
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'snippet.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42isomhvc1
creation_time : 2021-05-30T14:23:59.000000Z
Duration: 00:54:23.92, start: 0.000000, bitrate: 11430 kb/s
Stream #0:0(und): Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 9269 kb/s, 23.98 fps, 24 tbr, 12288 tbn, 24 tbc (default)
Metadata:
creation_time : 2021-05-30T14:23:59.000000Z
handler_name : Video Media Handler
encoder : HEVC Coding
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 1081 kb/s (default)
Metadata:
creation_time : 2021-05-30T14:23:59.000000Z
handler_name : Sound Media Handler
Stream #0:2(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 1074 kb/s (default)
Metadata:
creation_time : 2021-05-30T14:23:59.000000Z
handler_name : Sound Media Handler
Stream mapping:
Stream #0:0 -> #0:0 (hevc (native) -> hevc (libx265))
Stream #0:1 -> #0:1 (copy)
Stream #0:2 -> #0:2 (copy)
Press [q] to stop, [?] for help
x265 [info]: HEVC encoder version 3.4+32-b24459657
x265 [info]: build info [Windows][GCC 10.2.0][64 bit] 8bit+10bit+12bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x265 [info]: Main profile, Level-4 (Main tier)
x265 [info]: Thread pool created using 32 threads
x265 [info]: Slices : 1
x265 [info]: frame threads / pool features : 5 / wpp(17 rows)
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 3 inter / 3 intra
x265 [info]: ME / range / subpel / merge : star / 57 / 4 / 4
x265 [info]: Keyframe min / max / scenecut / bias : 24 / 250 / 40 / 5.00
x265 [info]: Lookahead / bframes / badapt : 40 / 8 / 2
x265 [info]: b-pyramid / weightp / weightb : 1 / 1 / 1
x265 [info]: References / ref-limit cu / depth : 5 / off / on
x265 [info]: AQ: mode / str / qg-size / cu-tree : 2 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress : CRF-21.0 / 0.60
x265 [info]: tools: rect amp limit-modes rd=6 psy-rd=2.00 rdoq=2 psy-rdoq=1.00
x265 [info]: tools: rskip mode=1 limit-tu=4 signhide tmvp b-intra
x265 [info]: tools: strong-intra-smoothing deblock sao
Output #0, matroska, to 'snippet.mkv':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42isomhvc1
encoder : Lavf58.45.100
Stream #0:0(und): Video: hevc (libx265), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 24 fps, 1k tbn, 24 tbc (default)
Metadata:
creation_time : 2021-05-30T14:23:59.000000Z
handler_name : Video Media Handler
encoder : Lavc58.91.100 libx265
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1(und): Audio: aac (LC) ([255][0][0][0] / 0x00FF), 48000 Hz, 5.1, fltp, 1081 kb/s (default)
Metadata:
creation_time : 2021-05-30T14:23:59.000000Z
handler_name : Sound Media Handler
Stream #0:2(und): Audio: aac (LC) ([255][0][0][0] / 0x00FF), 48000 Hz, 5.1, fltp, 1074 kb/s (default)
Metadata:
creation_time : 2021-05-30T14:23:59.000000Z
handler_name : Sound Media Handler
如您所见,输入文件的帧率为 23.98 fps,输出文件的帧率为 24 fps。请问我遗漏了什么?
编辑:不幸的是,将输出容器更改为 mp4 并没有改变什么:
Output #0, mp4, to 'snippet.new.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42isomhvc1
encoder : Lavf58.45.100
Stream #0:0(und): Video: hevc (libx265) (hev1 / 0x31766568), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 24 fps, 12288 tbn, 24 tbc (default)
Metadata:
creation_time : 2021-05-30T14:23:59.000000Z
handler_name : Video Media Handler
encoder : Lavc58.91.100 libx265
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 1081 kb/s (default)
Metadata:
creation_time : 2021-05-30T14:23:59.000000Z
handler_name : Sound Media Handler
Stream #0:2(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 1074 kb/s (default)
Metadata:
creation_time : 2021-05-30T14:23:59.000000Z
handler_name : Sound Media Handler
答案1
Matroska 使用固定时间尺度 1000(此处的源 MP4 使用 12288),因此由于四舍五入,时间精度会丢失,并且无法在目标文件中准确表示 23.98。