Skip to content

demux_mkv: don't apply AVI b-frame delay compensation to VfW tracks#18091

Merged
kasper93 merged 1 commit into
mpv-player:masterfrom
kasper93:avi-dts
Jun 17, 2026
Merged

demux_mkv: don't apply AVI b-frame delay compensation to VfW tracks#18091
kasper93 merged 1 commit into
mpv-player:masterfrom
kasper93:avi-dts

Conversation

@kasper93

@kasper93 kasper93 commented Jun 7, 2026

Copy link
Copy Markdown
Member

crazy_video_pts_stuff() shifts video PTS back by the codec delay to undo libavcodec returning frames paired with a later packet's DTS. This is only correct for genuine AVI, where DTS are decode-order frame indices.

VfW-muxed Matroska looks similar but its block timestamps are real DTS, already offset by the reorder delay, so the libavcodec shift cancels the offset and no compensation is needed. Applying it anyway pushed video one frame ahead of audio (e.g. VC-1, whose Advanced Profile always reports has_b_frames=1).

Split the avi_dts flag. Deep DTS routing for VfW mkv via a new block_dts, and reserve avi_dts for genuine AVI only.

Note that demux_lavf for Matroska was already not affected, because avi_dts wouldn't be set for those.

Fixes #18089

crazy_video_pts_stuff() shifts video PTS back by the codec delay to undo
libavcodec returning frames paired with a later packet's DTS. This is
only correct for genuine AVI, where DTS are decode-order frame indices.

VfW-muxed Matroska looks similar but its block timestamps are real DTS,
already offset by the reorder delay, so the libavcodec shift cancels the
offset and no compensation is needed. Applying it anyway pushed video
one frame ahead of audio (e.g. VC-1, whose Advanced Profile always
reports has_b_frames=1).

Split the `avi_dts` flag. Deep DTS routing for VfW mkv via a new
`block_dts`, and reserve avi_dts for genuine AVI only.

Note that demux_lavf for Matroska was already not affected, because
`avi_dts` wouldn't be set for those.

Fixes mpv-player#18089
@kasper93 kasper93 merged commit f8150c7 into mpv-player:master Jun 17, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect timestamp compensation for VFW-muxed (VC-1) mkv streams

1 participant