[FFmpeg-devel] [RFC] dts and ac3 autodetection in wav
Benjamin Larsson
banan
Sat Apr 19 12:14:43 CEST 2008
Michael Niedermayer wrote:
> On Fri, Apr 18, 2008 at 11:42:28PM +0200, Benjamin Larsson wrote:
>> Hi, this is just a first try. For some reason ac3 detection works but
>> the audio doesn't play
>
> try -acodec copy -f image2 frame%d.raw
> and look at the result are these valid ac3 frames
> also i assume the file does play with some other player
>
I think I know the issue for AC3, the bitstream might be byteswapped.
>
>> and dts gets the channel count wrong. So what is
>> wrong with this approach?
>
> well where is the channel number set? wav.c likely does set it
It does.
>, is this
> value correct?
No.
> next comes the parser it seems out dts parser does not
> set the channels,
Correct.
> and last is the decoder,
ffmpeg -i dtsinwav.wav does not execute the decoder, so even if I set
the channels to 0 it doesn't work. Do I need to NULL the samplerate and
other parameters to make it call the decoder ?
> it does a
> if (!avctx->channels)
> before setting the channels
>
>
>
>
> [...]
>> Index: libavformat/wav.c
>> ===================================================================
>> --- libavformat/wav.c (revision 12892)
>> +++ libavformat/wav.c (working copy)
>> @@ -139,7 +139,7 @@
>> static int wav_probe(AVProbeData *p)
>> {
>> /* check file header */
>> - if (p->buf_size <= 32)
>> + if (p->buf_size < PROBESIZE)
>> return 0;
>> if (p->buf[0] == 'R' && p->buf[1] == 'I' &&
>> p->buf[2] == 'F' && p->buf[3] == 'F' &&
>
> i do not understand this check, the code uses the wav demuxer anyway
> so this shouldnt be needed
Well the size needs to be >32 otherwise there wont be enough data to
parse through to find the dts syncword. I found it at position 3070
something in one file. So I set it to 4096. I think this has to do with
the streamability of the file.
>
>
> [...]
>> @@ -186,6 +242,10 @@
>> size = find_tag(pb, MKTAG('d', 'a', 't', 'a'));
>> if (size < 0)
>> return -1;
>> +
>> + /* check if it's really PCM or hidden DTS */
>> + if (codec_get_id (codec_wav_tags, st->codec->codec_tag) == CODEC_ID_PCM_S16LE)
>> + find_dts_ac3_header (pb, st->codec);
>
> analyzing stream content to set the codec could be done in
> set_codec_from_probe_data()
> its not without issues but its better to keep such code together i think
>
I don't understand how that should be done.
MvH
Benjamin Larsson
More information about the ffmpeg-devel
mailing list