Skip to content

VC-1 software decoder fails with "Picture size 0x0 is invalid" on some post-seek landings, dropping frames #490

Closed

Description

@classicjazz

What happened?

After a subset of programmatic seeks, a freshly-opened VC-1 decoder context logs a hard decode error instead of the routine "first frame is no keyframe" warning that every other seek produces:

[vc1 @ 0x...] [IMGUTILS @ 0x...] [error] Picture size 0x0 is invalid
[vc1 @ 0x...] [error] Failed to set dimensions 0 0

Each occurrence coincides with a layerDrop jump in the next diagnostic sample (frames are lost, not just delayed). Observed 4 times across 3 sessions: once on progressive 23.976fps content (FileD, after seek to 1237.56s) and 3 times on interlaced 29.97i content (FileF, after seeks to 2125.91s and 1973.56s across two separate sessions of the same episode). It is not specific to the deinterlace path, but occurs more often on interlaced content in this sample.

Steps to reproduce

  1. Open a VC-1 (software path) file — reproduces on both a progressive file (FileD) and an interlaced file (FileF).
  2. Perform several programmatic seeks to arbitrary timestamps in succession.
  3. Watch for [IMGUTILS] Picture size 0x0 is invalid in the log — it doesn't fire on every seek, only some.

AetherEngine version or commit SHA

6.68.0

Host app

AetherPlayer

Platform

macOS

OS version

macOS 27

Device / chip

Mac M1 Studio Max

Playback path

Software (dav1d) host

Source media (for playback bugs)

No response

Error codes / log lines


Anything else

This looks like a more severe version of the same landing condition that produces the ubiquitous "first frame is no keyframe" warning (seeking mid-GOP, before a full reference chain is available) — but here the decoder fails hard enough to report zero dimensions for that frame instead of just warning and continuing. Sample diagnostic context (FileF, second occurrence):

18:05:40.325Z  [vc1 @ 0x7ca2661880] [IMGUTILS @ 0x16dd0db68] [error] Picture size 0x0 is invalid
18:05:40.325Z  [vc1 @ 0x7ca2661880] [error] Failed to set dimensions 0 0

No corresponding corrupt counter increment and no crash — the frame is simply dropped and playback continues. Given it reproduces on both a progressive and an interlaced file, this is likely a general VC-1 reference-picture-buffer edge case on seek landing rather than something deinterlace-specific, but the sample size on interlaced content (3 of 4 occurrences) suggests it's more easily triggered there — possibly because interlaced GOPs land the software decoder on a bad reference frame more often.

Activity

  1. added
    bug
    on Sep 5, 2026
  2. superuser404notfound commented on Sep 5, 2026

    @superuser404notfound
    Owner

    Traced. The context that logs this is not the decoder, it is the VC-1 PARSER, and "freshly-opened" is exactly right: it is freshly opened at every seek, by libavformat, on purpose.

    The chain. ff_read_frame_flush runs on every reposition and does av_parser_close(sti->parser); sti->parser = NULL, so each seek gets a genuinely new VC1ParseContext with its VC1Context zeroed. vc1_parser.c never seeds that context from avctx->extradata; only the decoder does that, at init. So on a fresh parser max_coded_width and max_coded_height are 0 until an in-stream sequence header BDU comes past. ff_vc1_decode_entry_point (vc1.c:525) falls back to exactly those two fields when the entry point carries no coded size of its own, and ff_set_dimensions(avctx, 0, 0) then fails with the two lines quoted. The parser ignores the return value, so nothing is thrown away on account of it.

    That accounts for "only some seeks" without needing a reference-chain story: it fires when the landing keyframe's BDUs carry an entry point but no sequence header, and stays quiet when a sequence header precedes it, which is a property of the encoder rather than of the seek.

    The same uninitialised context does more than log, and that part is measurable. With v.profile still 0 the parser reads an advanced-profile frame header through the simple/main reader, so pict_type and field_order are whatever falls out. libavformat then overwrites the packet's keyframe flag from that (demux.c:1296-1302), and matroskadec forces need_parsing = AVSTREAM_PARSE_HEADERS on every non-HEVC video track (matroskadec.c:3046), so the parser is unavoidably in the path for a Matroska VC-1 remux.

    Measured on a WVC1 remux here (Test_1440x576_WVC1_6Mbps.wmv, -c copy to MKV):

    ffprobe -select_streams v:0 -show_entries packet=flags        1451 of 1451 packets flagged K
    ffprobe -fflags +noparse -select_streams v:0 ... same         10 of 1451 flagged K
    

    Ten is the container truth. The file on disk carries ten key bits and Cues at those same ten timestamps. So the parser is inflating every packet to a keyframe on this track type. Seeking is unaffected, because avformat_seek_file uses the Cues index, which is built before the parser ever runs, but it is a real corruption of the packet flags and it is the same defect that produces the ubiquitous "first frame is no keyframe" warning.

    On the frame loss. I would not attribute it to this yet. All four occurrences are at seek landings, and every seek costs frames on this path whether or not the line appears, so the coincidence with a layerDrop step is expected rather than evidence. The per-seek drop rate is worth pursuing on its own terms, which is the other issue.

    Where the fix belongs. This is upstream: the VC-1 parser should seed its context from extradata the way the decoder does, and the forced need_parsing on a Matroska VC-1 track is questionable in its own right given the blocks are already frame-aligned. FFmpegBuild carries a small set of local patches for cases like this and already upstreams them, so it is a candidate for both. No date on it, and it is behind the seek-reference fix in priority, since that one is user-visible and this one is a log line plus a flag nobody on this path reads.

  3. superuser404notfound commented on Sep 10, 2026

    @superuser404notfound
    Owner

    Two updates, and the first one is a correction to my last comment.

    The key frame flags: right observation, wrong mechanism

    I wrote that the inflated flags follow from the uninitialised context, that with v.profile still 0 the parser reads an advanced profile frame header through the simple/main reader and that libavformat then takes pict_type from that. The numbers were real and reproduce exactly, but that explanation is wrong.

    Instrumenting the parser on the same file shows vc1_extract_header() is called zero times across all 1451 packets. Matroska stores VC-1 without start codes (the first packet begins c0 22 00 00 03 ..., no 00 00 01 0D), and this parser finds its headers by scanning for start codes, so on that track it never parses anything at all. What sets the flag is a default: av_parser_init() (libavcodec/parser.c) leaves pict_type at AV_PICTURE_TYPE_I, and the parse path in libavformat/demux.c marks a packet a key frame when the parser reports AV_PICTURE_TYPE_I with key_frame unset. So the flags come from a parser that determined nothing, not from one that determined the wrong thing.

    Fixed upstream as a one-liner: the parser reports AV_PICTURE_TYPE_NONE until it has actually read a frame header, which leaves the flag to the container. On the same file, parsed goes from 1451 of 1451 to 10 of 1451, which is what the container carries and what -fflags +noparse reports. All nine vc1 FATE tests pass, and the two shapes that could have regressed do not: a raw .vc1 stream (no container flags at all) still gets its key frame from the parser, and the same stream remuxed to Matroska with start codes is unchanged.

    https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24439

    The reported error itself does not reproduce here

    Picture size 0x0 is invalid did not appear once on that asset, on any of four seek points, with or without a patched parser. My proposed fix for it, seeding the parse context from extradata the way the decoder does at init, was built and measured: it works in the sense that the seeded context comes out with profile 3 and 1440x576 instead of zeroes, but with no reproduction of the error there is nothing behind the claim that it fixes what you reported, so it has not been submitted anywhere.

    What would settle it is a session that produces the line. Two things from your side would do it, whenever it is convenient:

    1. the ten or so log lines around one occurrence, in particular whether a video gate open: or a seek line sits just before it, so the axis is clear;
    2. whether the video track of FileD or FileF carries start codes, which is one command:
    ffprobe -v error -fflags +noparse -select_streams v:0 -show_packets -show_data -read_intervals "%+#1" FileD.mkv | head -5
    

    If those first bytes are 00 00 01 0D, your files are the shape my extradata theory needs and the fix is worth building properly. If they look like the sample here, the error has a different origin and the theory can go.

    Nothing in either half changes the per-seek drop rates, which stay on the other issue.

  4. classicjazz commented on Sep 10, 2026

    @classicjazz
    Author

    ffprobe payload dump on the affected files — V_MS/VFW/FOURCC WVC1 in Matroska, and they do carry Annex‑E start codes: first packet is 00 00 01 0F / 00 00 01 0E / 00 00 01 0D (seq header, entry point, frame). So the parser is active on this track — not the no‑start‑code shape your fixture had. Which puts it back on your original read: fresh parse context per seek, max_coded_width/height zero until an in‑stream sequence header passes.

    Re‑ran ~70 programmatic seeks across four WVC1‑in‑MKV files on Aether 6.68.2 (two interlaced 29.97i, two progressive 23.976), scattered targets across the whole duration plus a few rapid pairs — no Picture size 0x0 on any of them. So the trigger looks specific to the GOP structure of the originals (entry‑point BDUs reachable by seek that carry no in‑packet sequence header), consistent with "a property of the encoder rather than of the seek." I'll capture the surrounding lines if it recurs in normal use.

  5. superuser404notfound commented on Sep 11, 2026

    @superuser404notfound
    Owner

    That dump settled it, thank you. It is the piece that was missing, and it also explains the non-reproduction here.

    Why it never fired on my fixture

    Test_1440x576_WVC1_6Mbps.wmv remuxed to MKV stores VC-1 without start codes, so vc1_extract_header() ran zero times on that track. The parser was in the path and read nothing, which is a different defect (the one PR 24439 covers) and structurally incapable of producing this error. Your files carry Annex-E, so the parser really parses, and the original read applies to them.

    The mechanism, in full

    Reproduced here now, and there is a second half I had not accounted for.

    The necessary condition is the one already on this thread: ff_read_frame_flush() closes the parser on every reposition, vc1_parser.c never seeds its VC1Context from avctx->extradata, so a landing packet whose entry point has no sequence header in front of it reaches a context with profile 0 and max_coded_width/max_coded_height 0.

    The sufficient condition is a single bit. ff_vc1_decode_entry_point() skips hrd_full[] before reading coded_size_flag, but only when hrd_param_flag was set in the sequence header, which a zeroed context cannot know. So it reads coded_size_flag at the wrong bit offset, and the bit it lands on is the top bit of hrd_full[0]: the leaky bucket fullness at that entry point.

    • bucket below half full → reads 0 → falls back to max_coded_width/max_coded_height → ff_set_dimensions(avctx, 0, 0) fails → the two lines you quoted;
    • bucket above half full → reads 1 → takes a 24 bit coded size out of the following payload → a wrong size that ff_set_dimensions() accepts, no log line at all.

    Rate control moves that fullness from GOP to GOP. That is the "only some seeks", and it also fits your 70 seek re-run finding none: a landing has to hit a GOP that both omits the repeated sequence header and had its bucket below half at that point.

    Reproduction, on a public sample

    VC1_interlaced_1080i60_with_artifacts_crashes.mkv from samples.ffmpeg.org is 1080i60 WVC1 in Matroska with Annex-E, so it is the shape of your files. As published it repeats the sequence header at every entry point and its hrd_full[0] sits above half, so it stays quiet. A generator (in the PR below) makes the two edits that occur in the wild but not in this file: drop the repeated sequence headers, clear the top bit of hrd_full[0].

    ffmpeg -i VC1_interlaced_1080i60_with_artifacts_crashes.mkv -map 0:v:0 -c copy -f data traviata.vc1
    python3 gen_vc1_seek_repro.py traviata.vc1 repro.vc1
    ffmpeg -r 30000/1001 -f vc1 -i repro.vc1 -c copy repro.mkv
    ffprobe -read_intervals "2.1%+#4" repro.mkv

    Six seek points (1.1, 1.4, 1.7, 2.1, 2.4, 2.7 s):

    Picture size 0x0 is invalid
    FFmpeg master 6 of 6
    with the patch 0 of 6

    A linear read is byte identical either way (packet=flags,pts,dts,duration matches on the repro, on the unmodified sample, on the raw elementary stream, and on two VC-1 FATE samples), and all nine vc1 FATE tests pass.

    Fix

    Submitted upstream: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24458, parse extradata once per parser instance the way vc1_decode_init() does. It removes the class rather than the log line: the same zeroed context sends an advanced profile frame header through the simple/main reader, and libavformat takes the packet key flag from the pict_type that comes out of it and computes packet duration from its repeat_pict.

    This is not in any AetherEngine build. Carrying it as a local FFmpegBuild patch ahead of the upstream merge is a separate call, and I will note here whichever way it goes.

    On the frame loss

    Unchanged: the layerDrop coincidence is what a seek landing costs either way, and the one that was a real defect there is #494, released in 6.68.4. On the software path nothing routes on the packet key flag, so what this issue costs on this stack is the log line and the wrong parser side values behind it.

  6. superuser404notfound commented on Sep 11, 2026

    @superuser404notfound
    Owner

    Follow-up on where the fix stands, since the last comment left it open.

    Carried locally as a bundled FFmpeg patch in FFmpegBuild 3.2.1, rather than waiting for the upstream merge: https://github.com/superuser404notfound/FFmpegBuild/releases/tag/3.2.1. VC1ParserExtradataTests drives the shipped libavcodec through av_parser_parse2 and pins both bucket cases; against the 3.2.0 binaries they fail with 0x0 and with 2050x2, which are the two forms described above, while the fixture control passes, so the synthetic BDUs are sound.

    Verified end to end through the engine on the 29 s reproducer, one programmatic seek onto a landing with no sequence header in front of its entry point:

    [AetherEngine] seek#1 programmatic landed rendered=20.00 target=20.00
      SEEKLANDED target=20.00 in 8ms (clock=20.00)
    [vc1 @ 0x766e40380] [IMGUTILS @ 0x16c145d78] [error] Picture size 0x0 is invalid
    [vc1 @ 0x766e40380] [error] Failed to set dimensions 0 0
    

    That is FFmpegBuild 3.2.0. On 3.2.1 the same run produces neither line.

    Not in a released engine yet. The uptake is on main and will go out with the next release; there is nothing to retest against before then, and I will post the version here when there is.

  7. superuser404notfound commented on Sep 11, 2026

    @superuser404notfound
    Owner

    Released in 6.81.0: the parse-context seeding from FFmpegBuild 3.2.1 is in this build (4417e018, merged as 3efd129c). Both consumers are pinned to it.

    @classicjazz, a seek on a VC-1 track should no longer land the parser without a picture size. Leaving this open for your retest.

  8. classicjazz commented on Sep 17, 2026

    @classicjazz
    Author

    Retested on AetherPlayer 0.18.1/69, macOS 27.0 4 separate VC-1 (WMV-remuxed, tag=WVC1) files, seeking repeatedly on each — 36 seeks total (7, 11, 11, 7 per file), all landed cleanly.

    Picture size 0x0 is invalid does not appear in any of the four diagnostic logs. Confirms the fix in 6.81.0 (FFmpegBuild 3.2.1, 4417e018) holds through the seek path this issue was about.

    I recommend closing this issue.

  9. superuser404notfound commented on Sep 17, 2026

    @superuser404notfound
    Owner

    Thank you for the re-run, and for the ffprobe dump earlier in the thread. That dump is what turned this from a theory that did not reproduce into a mechanism with a test behind it: it told me your tracks carry Annex-E start codes, which is the shape my fixture did not have, and everything after it followed from that.

    36 seeks across four WVC1 files with no occurrence is the acceptance. Closing.

    For the record of where the fix lives: the parse-context seeding ships as a bundled FFmpeg patch in FFmpegBuild 3.2.1 and reached the engine in 6.81.0, so every build since carries it. Upstream the two parser patches are still open (https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24439 and https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24458), and the local patch stays in place until they land. If either one changes shape on review, the pinned VC1ParserExtradataTests will catch a divergence before it reaches a build.

    The per-seek frame loss stays where it was, unrelated to this line, and the one real defect there went out as #494 in 6.68.4.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions