Не могу разобраться с monotonous DTS в h264. Ffmpeg ругается, что DTS увеличивается не монотонно. Также сыпятся сообщения из libx264: non-strictly-monotonic.
ffmpeg -y -loglevel repeat+info -i bad_7s.mp4 -vsync 0 out.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'bad_7s.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.12.100
Duration: 00:01:04.33, start: 0.000000, bitrate: 1656 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 480x270, 1654 kb/s, 24.42 fps, 16k tbr, 16k tbn, 32k tbc (default)
Metadata:
handler_name : VideoHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x6473e80] using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX
[libx264 @ 0x6473e80] profile High, level 2.1
[libx264 @ 0x6473e80] 264 - core 155 r2901 7d0ff22 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: 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=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'out.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.12.100
Stream #0:0(und): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 480x270, q=-1--1, 24.42 fps, 1571k tbn, 24.42 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc58.18.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
[libx264 @ 0x6473e80] non-strictly-monotonic PTS
[libx264 @ 0x6473e80] non-strictly-monotonic PTS
[libx264 @ 0x6473e80] non-strictly-monotonic PTS
[libx264 @ 0x6473e80] non-strictly-monotonic PTS
[libx264 @ 0x6473e80] non-strictly-monotonic PTS
[libx264 @ 0x6473e80] non-strictly-monotonic PTS
[libx264 @ 0x6473e80] non-strictly-monotonic PTS
[libx264 @ 0x6473e80] non-strictly-monotonic PTS
[libx264 @ 0x6473e80] non-strictly-monotonic PTS
[libx264 @ 0x6473e80] non-strictly-monotonic PTS
[libx264 @ 0x6473e80] non-strictly-monotonic PTS
[mp4 @ 0x6475540] Non-monotonous DTS in output stream 0:0; previous: 0, current: 0; changing to 1. This may result in incorrect timestamps in the output file.
[libx264 @ 0x6473e80] non-strictly-monotonic PTS
[mp4 @ 0x6475540] Non-monotonous DTS in output stream 0:0; previous: 192993, current: 192993; changing to 192994. This may result in incorrect timestamps in the output file.
[mp4 @ 0x6475540] Non-monotonous DTS in output stream 0:0; previous: 321655, current: 321655; changing to 321656. This may result in incorrect timestamps in the output file.
[mp4 @ 0x6475540] Non-monotonous DTS in output stream 0:0; previous: 771972, current: 771972; changing to 771973. This may result in incorrect timestamps in the output file.
[libx264 @ 0x6473e80] non-strictly-monotonic PTS
[mp4 @ 0x6475540] Non-monotonous DTS in output stream 0:0; previous: 900634, current: 900634; changing to 900635. This may result in incorrect timestamps in the output file.
[libx264 @ 0x6473e80] non-strictly-monotonic PTS
[mp4 @ 0x6475540] Non-monotonous DTS in output stream 0:0; previous: 1029296, current: 1029296; changing to 1029297. This may result in incorrect timestamps in the output file.
[libx264 @ 0x6473e80] non-strictly-monotonic PTS
[mp4 @ 0x6475540] Non-monotonous DTS in output stream 0:0; previous: 1157958, current: 1157958; changing to 1157959. This may result in incorrect timestamps in the output file.
[libx264 @ 0x6473e80] non-strictly-monotonic PTS
[mp4 @ 0x6475540] Non-monotonous DTS in output stream 0:0; previous: 1415282, current: 1415282; changing to 1415283. This may result in incorrect timestamps in the output file.
[libx264 @ 0x6473e80] non-strictly-monotonic PTS
[libx264 @ 0x6473e80] non-strictly-monotonic PTS
[mp4 @ 0x6475540] Non-monotonous DTS in output stream 0:0; previous: 1801268, current: 1801268; changing to 1801269. This may result in incorrect timestamps in the output file.
Как я понял, DTS должен увеличиваться (что логично). Посмотрел исходники libx264 https://code.videolan.org/videolan/x264/-/blob/master/encoder/encoder.c#L3325
if( h->param.b_vfr_input && fenc->i_pts <= h->frames.i_largest_pts )
x264_log( h, X264_LOG_WARNING, "non-strictly-monotonic PTS\n" );
из чего следует(по моей логике), что если текущий PTS меньше или равен предыдущему (точнее самому большому значению всех предыдущих PTS?), то выводится предупреждение
Распарсил свой видеоролик
ffprobe -show_frames -select_streams v:0 bad_7s.mp4
И не увидел там плохих DTS\PTS(они всегда равны в моем случае). Я даже написал простой скрипт, который бы находил эти «плохие» DTS
Выгрузил в json информацию о всех фреймах
ffprobe -show_frames -select_streams v:0 -print_format json bad_7s.mp4 > frames.json
node parse.js
const fs = require("fs");
var data = JSON.parse(fs.readFileSync("frames.json").toString());
var largest_dst;
for(var item of data.frames){
var dts = item.pkt_dts;
var pts = item.pkt_pts;
if(dts !== pts) {
console.error("error", item);
process.exit();
}
if(largest_dst && dts <= largest_dst){
console.error(item);
}
if(!largest_dst || dts > largest_dst){
largest_dst = dts;
}
}
...и скрипт не нашел ничего, вывод пустой. Все DTS увеличиваются!
Что я делаю\понимаю не так?
Все фреймы в формате csv
https://pastebin.com/B9DtFsPR