[FFmpeg-devel] [PATCH] fix swf playback with bad audio track
Aurelien Jacobs
aurel
Tue Sep 11 11:24:15 CEST 2007
On Tue, 11 Sep 2007 01:20:23 +0200
Baptiste Coudurier <baptiste.coudurier at smartjog.com> wrote:
> Hi
>
> Aurelien Jacobs wrote:
> > Hi,
> >
> > Right now, when the swf demuxer find an audio track with unrecognized
> > samplerate, it simply return AVERROR(EIO). This prevent playing the
> > video track.
>
> It seems weird, samplerate should not be "unrecognized", Im curious, is
> such a file available somewhere ?
To be more precise, sample_rate_code has 2 significant bits. Values
between 1 and 3 maps to samplerate 11025, 22050 and 44100.
sample_rate_code == 0 don't map to any samplerate (at least in current
code).
Here is a sample which has sample_rate_code = 0:
http://samples.mplayerhq.hu/SWF/962_fws.swf
> > With the attached patch, the swf demuxer simply ignore the unrecognized
> > audio track, but still allows to play the video track of such a file.
> >
> > Aurel
> >
> >
> > ------------------------------------------------------------------------
> >
> > Index: libavformat/swf.c
> > ===================================================================
> > --- libavformat/swf.c (revision 10438)
> > +++ libavformat/swf.c (working copy)
> > @@ -682,17 +682,17 @@
> > get_byte(pb);
> > v = get_byte(pb);
> > swf->samples_per_frame = get_le16(pb);
> > + sample_rate_code= (v>>2) & 3;
> > + if (sample_rate_code) {
> > ast = av_new_stream(s, -1); /* -1 to avoid clash with video stream ch_id */
> > swf->audio_stream_index = ast->index;
> > ast->codec->channels = 1 + (v&1);
> > ast->codec->codec_type = CODEC_TYPE_AUDIO;
> > ast->codec->codec_id = codec_get_id(swf_audio_codec_tags, (v>>4) & 15);
> > ast->need_parsing = AVSTREAM_PARSE_FULL;
> > - sample_rate_code= (v>>2) & 3;
> > - if (!sample_rate_code)
> > - return AVERROR(EIO);
> > ast->codec->sample_rate = 11025 << (sample_rate_code-1);
> > av_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
> > + }
> > len -= 4;
> > } else if (tag == TAG_VIDEOFRAME) {
> > int ch_id = get_le16(pb);
> >
>
> Im not against it, though maybe we should still export the track, to
> permit stream copy/extraction somehow. I'd like to know which codec it
> is supposed to be.
Trying to play the above mentioned file with mplayer -demuxer audio
shows the following informations (and audio plays fine):
Audio file file format detected.
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
AUDIO: 11025 Hz, 2 ch, s16le, 16.0 kbit/4.54% (ratio: 2000->44100)
Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)
==========================================================================
I suppose the swf demuxer would require some more love to understand
this track header.
In the meantime, I guess I will apply this patch, unless you disagree.
Aurel
More information about the ffmpeg-devel
mailing list