Opened 8 weeks ago

Last modified 8 weeks ago

#11196 new defect

ffmpeg is unable to identify/open mpeg 2/3 files with only one frame

Reported by: Greisberger Christophe Owned by:
Priority: normal Component: avformat
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
How to reproduce:

% ffmpeg -i input.21 output.wav
[mp3 @ 000001A7C88A2C00] Format mp3 detected only with low score of 1, misdetection possible!
[mp3 @ 000001A7C88A2C00] Invalid frame size (768): Could not seek to 768.
[in#0 @ 000001A7C887E040] Error opening input: Invalid argument
Error opening input file input.21.
Error opening input files: Invalid argument

I tracked the problem in libavformat/mp3_dec.c here:

mp3_read_header(AVFormatContext *s)
{
   ...
            ffio_ensure_seekback(s->pb, i + 1024 + frame_size + 4);
            ret = check(s->pb, off + i + frame_size, &header2);
            if (ret >= 0 &&
                (header & MP3_MASK) == (header2 & MP3_MASK))
            {
                break;
            } else if (ret == CHECK_SEEK_FAILED) {
                av_log(s, AV_LOG_ERROR, "Invalid frame size (%d): Could not seek to %"PRId64".\n", frame_size, off + i + frame_size);
                return AVERROR(EINVAL);
            }

It seeks to the end of the 1st (any unique) frame, then fails to read 4 bytes (of course).

With files with at least 2 frames, it works

Attachments (4)

sample.21 (768 bytes ) - added by Greisberger Christophe 8 weeks ago.
MPEG 2 file (1 frame)
sample.31 (768 bytes ) - added by Greisberger Christophe 8 weeks ago.
MPEG 3 file (1 frame)
sample.22 (1.5 KB ) - added by Greisberger Christophe 8 weeks ago.
MPEG 2 file (2 frames)
sample.32 (1.5 KB ) - added by Greisberger Christophe 8 weeks ago.
MPEG 3 file (2 frames)

Download all attachments as: .zip

Change History (5)

by Greisberger Christophe, 8 weeks ago

Attachment: sample.21 added

MPEG 2 file (1 frame)

by Greisberger Christophe, 8 weeks ago

Attachment: sample.31 added

MPEG 3 file (1 frame)

by Greisberger Christophe, 8 weeks ago

Attachment: sample.22 added

MPEG 2 file (2 frames)

by Greisberger Christophe, 8 weeks ago

Attachment: sample.32 added

MPEG 3 file (2 frames)

comment:1 by Balling, 8 weeks ago

To be fair same happens with very small EAC3 files.

Note: See TracTickets for help on using tickets.