[FFmpeg-devel] [PATCH] use Xing tag to read duration from mp3 files

Benjamin Larsson banan
Tue Oct 23 13:38:51 CEST 2007


Hi,

Andreas ?man wrote:
> Hi
>
> The attached patch does $subj
>
> It was based on the info from
> http://www.codeproject.com/audio/MPEGAudioInfo.asp
>
>
> ------------------------------------------------------------------------
>
> Index: libavformat/mp3.c
> ===================================================================
> --- libavformat/mp3.c	(revision 10844)
> +++ libavformat/mp3.c	(working copy)
> @@ -21,6 +21,7 @@
>  #include "avformat.h"
>  #include "mpegaudio.h"
>  #include "avstring.h"
> +#include "mpegaudiodecheader.h"
>  
>  #define ID3v2_HEADER_SIZE 10
>  #define ID3v1_TAG_SIZE 128
> @@ -424,12 +425,38 @@
>      else                   return 0;
>  }
>  
> +/**
> + * Try to extract a xing tag from the stream and if found, decode it
> + */
> +static void mp3_parse_xing(AVFormatContext *s, AVStream *st)
> +{
> +    uint32_t flags, frames, size, spf;
> +    const offset_t offtbl[2][2] = {{32, 17}, {17,9}};
> +    MPADecodeContext c;
> +    return;
> +
> +    ff_mpegaudio_decode_header(&c, get_be32(&s->pb));
> +    url_fseek(&s->pb, offtbl[c.lsf == 1][c.nb_channels == 1], SEEK_CUR);
> +    if(c.layer != 3 || get_be32(&s->pb) != MKBETAG('X', 'i', 'n', 'g'))
>   

Either 'Xing' or 'Info' from the page, have Info been deprecated or 
something ?

Can't you add support for VBRI also ?

And don't forget to close the roundup issue.

MvH
Benjamin Larsson






More information about the ffmpeg-devel mailing list