Ticket #543 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

FLV MP3 durations incur round-off error

Reported by: gbooker Owned by:
Priority: normal Milestone:
Component: Perian-Main Version: 1.2
Severity: normal Keywords:
Cc:

Description

Originally reported on forums:  http://forums.cocoaforge.com/viewtopic.php?f=25&t=23040 with file from:  http://dl.dropbox.com/u/12177874/Tormod123_flv_Audio.zip

Video and audio durations do not match within Perian. Video is 10:20 and audio is 9:53. In closer examination, I noticed that the av_read_frame returns a packet with a duration of 25 in a timescale of 1/1000. For MP3, this is always 26, regardless of the timescale. It is computed as 25 since the frame size is 209, the bitrate is 65536, and the sample rate is 22050 making the duration in the timescale = 209 * 1000 * 8 / 65536 = 25.51, which when rounded produces the correct result. FFmpeg does not compute it this way, but instead computes the decoded sample size of 209 * 22050 * 8 / 65536 = 562.55 which is rounded down to 562. This is then converted to time by dividing by the sample rate (in the track's timescale) resulting in 562 * 1000 / 22050 = 25.48 which is rounded down to 25, and thus the error.

This is caused by round-offs in two locations causing the incorrect value and the fact that 209 bytes per sample is not strictly 65536 bit/sec as stated by the FLV header but rather 64307. Marking FLV MP3 timestamps as untrusted in Perian solves this:

Attachments

flvmp3.diff Download (603 bytes) - added by gbooker 4 years ago.
Patch to not trust flv timestamps

Change History

Changed 4 years ago by gbooker

Patch to not trust flv timestamps

comment:1 Changed 4 years ago by gbooker

  • Status changed from new to closed
  • Resolution set to fixed

(In [1383]) Don't trust audio durations in FLV. Fixes #543

Note: See TracTickets for help on using tickets.