Opened 10 years ago

Closed 10 years ago

#3937 closed defect (needs_more_info)

Inaccurate MP3 seek

Reported by: sssr33 Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: mp3 seek
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
Seeks to incorrect position inside of avformat/mp3dec.c/mp3_seek()

This function have next code:

duration = av_rescale(st->duration, filesize, mp3->header_filesize - s->data_offset);

I will change it for more convenience:

int64_t headerDataSize = mp3->header_filesize - s->data_offset;
duration = av_rescale(st->duration, filesize, headerDataSize);

Here is file https://mega.co.nz/#!mtwQXSbJ!D7CDinj63ePIZWQuXe_9td8zjpySsH0sPZA2Joh3IF4

Original code will have (filesize / headerDataSize) > 1.0 on test file. And after that duration will be much greater than st->duration and I think this will cause inaccurate seek.

Have tried on ffplay from Zeranoe. And also have this bug in ffmpeg 2.3.3

How to reproduce:

% ffplay 05._Du_hast.mp3

And then seek to end and you will see that playback not stops.

Possible fix:

// at begining
int64_t headerDataSize = mp3->header_filesize - s->data_offset;

// original code...

// change duration = av_rescale(st->duration, filesize, mp3->header_filesize - s->data_offset); to this:
if (filesize <= headerDataSize)
{
    duration = av_rescale(st->duration, filesize, headerDataSize);
}
else
{
    duration = st->duration;
}

Change History (2)

in reply to:  description comment:1 by Carl Eugen Hoyos, 10 years ago

Keywords: avformat removed
Version: 2.3git-master

Replying to sssr33:

How to reproduce:

% ffplay 05._Du_hast.mp3

And then seek to end and you will see that playback not stops.

I don't understand:
Seeking works fine for me in this file. Playback stops approximately at 3:56.
What is the problem?

If you found a fix for the problem you see, please send a patch to the development mailing list.

comment:2 by Carl Eugen Hoyos, 10 years ago

Resolution: needs_more_info
Status: newclosed

Please reopen this ticket if you can explain what goes wrong for the given sample.

Note: See TracTickets for help on using tickets.