[PATCH] avformat/demux: avoid unconditional ID3v2 tag consumption

Nil Fons Miret nilf at netflix.com
Wed Jul 9 01:07:35 EEST 2025


I have found a few instances of rawvideo files that coincidentally
start with a header matching the ID3v2 header format, and ffmpeg
consumes the header before demuxing, causing a decoding error. This
happens even if "-f rawvideo" is specified.

This patch limits the formats for which this automatic consuming of
ID3v2 headers is done. Note: I am not an expert in ID3v2 by any means,
and I'm happy to accept suggestions, both on the scope and mechanism
of the solution.

To reproduce, you can easily generate an example as follows:

```
(  echo "49 44 33 2B 98 3A 49 44 33 2B 98 3A 6A 44 54 2B" | xxd -r -p
  dd if=/dev/zero bs=1 count=115184 2>/dev/null
) > id3v2_320x240_yuv420p.yuv


ffmpeg -f rawvideo -s 320x240 -pix_fmt yuv420p -i
id3v2_320x240_yuv420p.yuv -f null -
```

This generates a 320x240 yuv420p file with a 16-byte header that
matches the ID3v2 header format (this was copied from a real case I
saw) and completed with zeroes for a total of 115200 bytes, the right
size for this resolution and pixel format.

On the master branch, I see:
```
[...]
ID3v2.43 tag skipped, cannot handle version
[...]
[out#0/null @ 0x15700a6e0] Output file is empty, nothing was
encoded(check -ss / -t / -frames parameters if used)
frame=    0 fps=0.0 q=0.0 Lsize=N/A time=N/A bitrate=N/A speed=N/A
```

After the changes: it decodes as expected.
```
[...]
frame=    1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A
speed=16.5x elapsed=0:00:00.00
```

Thanks in advance,
Nil
-------------- next part --------------
An embedded message was scrubbed...
From: nilfm <nil.fons at gmail.com>
Subject: [PATCH] avformat/demux: avoid unconditional ID3v2 tag consumption
Date: Wed, 2 Jul 2025 14:37:24 -0400
Size: 5108
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20250708/8a7421d9/attachment.eml>


More information about the ffmpeg-devel mailing list