Skip to content

MPEG-4 ASP / Xvid with B-frames plays in wrong frame order ("ping-pong" effect) #212

Open

Description

@dada25-source

MPEG-4 ASP / Xvid with B-frames plays in wrong frame order ("ping-pong" effect)

Environment

  • QuickLook Video: tested with 3.11 and 3.12
  • macOS 26
  • Apple Silicon M4
  • Video container: AVI
  • Video codec: MPEG-4 Advanced Simple Profile (Xvid)
  • Audio: MP3

Problem

AVI/Xvid videos containing B-frames do not play in the correct presentation order through Quick Look / QuickTime.

The video progresses normally in time, but individual frames repeatedly jump backwards and forwards, producing a very characteristic "ping-pong" effect.

The same AVI plays perfectly in IINA/mpv/FFmpeg.

Investigation

I tested an AVI containing:

Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658)
640x272
24000/1001 fps
Audio: MP3, 48000 Hz, stereo, 128 kb/s

First I used:

-bsf:v mpeg4_unpack_bframes

while copying both streams without re-encoding.

The resulting AVI still exhibits exactly the same ping-pong behaviour in Quick Look.

Therefore this does not appear to be caused specifically by packed B-frames.

I then inspected the timestamps. A remuxed sample shows this packet sequence:

PTS       DTS
0.042     0.001
0.125     0.042
0.083     0.083
0.167     0.125
0.250     0.167
0.209     0.209
0.292     0.250
0.375     0.292
0.334     0.334

So the stream requires normal B-frame reordering from decode order to presentation order.

Important A/B test

I re-encoded the first 60 seconds of exactly the same AVI back to Xvid, but explicitly disabled B-frames:

ffmpeg \
-i "input.avi" \
-t 60 \
-map 0:v:0 -map 0:a:0 \
-c:v libxvid \
-bf 0 \
-q:v 4 \
-c:a copy \
"output-no-bframes.avi"

Result:

Test Quick Look / QuickTime
AVI + Xvid with B-frames ❌ frames jump backwards/forwards
AVI + Xvid after mpeg4_unpack_bframes ❌ same problem
AVI + Xvid encoded with -bf 0 ✅ perfectly smooth
Same original AVI in IINA/mpv/FFmpeg ✅ perfectly smooth

I also previously tested replacing only the MPEG-4 ASP video with H.264 while keeping the same AVI container and MP3 audio. That also plays correctly.

Possible cause

This strongly suggests that the problem is not Xvid decoding itself, nor the AVI container, nor MP3 audio.

It appears to be related specifically to B-frame presentation reordering for MPEG-4 ASP/Xvid through the Media Extension / AVFoundation path.

The behaviour visually looks as if frames are being presented in decode/DTS order rather than correctly reordered into presentation/PTS order.

I noticed that QuickLook Video contains support related to frame reordering (requiresFrameReordering, maxBFrames and the MESampleCursor reordering methods), so perhaps the MPEG-4 ASP case is exposing an issue in this path.

Version observation

With QuickLook Video 3.11, MKV playback works normally for me, while the AVI/Xvid B-frame issue above remains.

After updating to 3.12 I additionally experienced problems with MKV preview, so I temporarily returned to 3.11 while investigating the AVI/Xvid issue.

I would be happy to perform additional FFmpeg/ffprobe tests if useful.

Activity

  1. Marginal commented on Oct 6, 2026

    @Marginal
    Owner

    Thanks for the report. There's some special handling for DivX/Xvid video (including doing the equivalent of -bsf:v mpeg4_unpack_bframes) that might possibly be causing the problem. Please remux to a different codec tag with ffmpeg -i input.avi -c copy -tag:v mp4v output.avi and see if that changes the behaviour.

    After updating to 3.12 I additionally experienced problems with MKV preview

    I'd be grateful if you would raise a separate issue for this. There are quite a few changes and optimisations between 3.11 and 3.12, but there shouldn't be any regressions. I'd like to get to the bottom of this.

  2. dada25-source commented on Oct 7, 2026

    @dada25-source
    Author

    Thanks. I tested exactly as suggested:
    ffmpeg -i input.avi -c copy -tag:v mp4v output.avi
    With the mp4v tag, Quick Look opens an empty white preview window with no video. The same remuxed AVI plays correctly in IINA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions