[FFmpeg-devel] Patch to WAV to accurately report duration

Justin Ruggles justin.ruggles
Wed Jan 12 23:44:19 CET 2011


On 01/12/2011 04:59 PM, Frank Barchard wrote:

> On Wed, Jan 12, 2011 at 8:04 AM, Michael Niedermayer <michaelni at gmx.at>wrote:
> 
>> On Mon, Jan 10, 2011 at 06:51:18PM -0800, Frank Barchard wrote:
>>> Patch to accurately report duration of a WAV.
>>
>> -    } else
>>> +    } else {
>>>          wav->data_end= url_ftell(pb) + size;
>>> +        st->nb_frames = size /
>>> +            (st->codec->channels * (st->codec->bits_per_coded_sample >>
>> 3));
>>> +        st->duration = st->codec->frame_size ?
>>> +            st->nb_frames * st->codec->frame_size : st->nb_frames;
>>> +    }
>>
>> this is wrong, iam not even sure its guranteed to work with PCM
>>
> 
> The patch has certainly worked for 8-bit, 16-bit, and 24-bit wav files that
> we've tested.  With the patch, the number of frames is reported as exactly
> right (as compared with the results returned by Apple's 'afinfo' tool).
>  Without the patch it is not accurate.


1) st->codec->frame_size has not even been set at this point

2) this looks like it will be completely wrong for anything other than
raw audio

-Justin



More information about the ffmpeg-devel mailing list