[FFmpeg-devel] UDP TS feed switching from EAC3 to AC3 audio
Michael Niedermayer
michaelni at gmx.at
Fri Sep 19 14:22:14 CEST 2014
On Thu, Sep 18, 2014 at 02:35:42PM -0600, Ryan Owen wrote:
> I have a TS feed that I'm reading with libavformat/libavcodec over
> multicast. The feed comes from an over-the-air channel, where the video is
> mpeg2 and the audio is AC3.
>
> Occasionally there are some dropped packets, and that somehow leads
> libavcodec/ac3_parser.c to think the audio codec has changed to EAC3.
> When this happens, I call avcodec_open2 with the new codec info, but it
> fails with the error "invalid extradata size" (the extradata size is 0).
> That is probably to be expected, because the audio frame is invalid due to
> the dropped packets anyway.
>
> The problem comes when the next valid audio frame arrives. ac3_parser.c
> has this logic in ac3_sync():
>
> if(hdr.bitstream_id>10)
> hdr_info->codec_id = AV_CODEC_ID_EAC3;
> else if (hdr_info->codec_id == AV_CODEC_ID_NONE)
> hdr_info->codec_id = AV_CODEC_ID_AC3;
>
> Because of the previous bad frame, hdr_info->codec_id got switched to
> AV_CODEC_ID_EAC3. But because of the "else if" condition, it can't switch
> back to AV_CODEC_ID_AC3. Even though the new frame is valid, avcodec_open2
> continues to fail because EAC3 doesn't like the extradata size to be 0.
>
> I'm wondering if it would be ok to change the "else if" to just an "else",
no
> or if that would break some other scenario. I don't know enough about
> AC3/EAC3 to understand why it shouldn't switch back to AC3.
there would be a race condition
>
> Any suggestions on how to work around this problem?
the decoder could make the switch, the parser cant switch the decoder
at least not easily
so the solution would be to check this in the decoder and switch there
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Concerning the gods, I have no means of knowing whether they exist or not
or of what sort they may be, because of the obscurity of the subject, and
the brevity of human life -- Protagoras
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140919/cdb51299/attachment.asc>
More information about the ffmpeg-devel
mailing list