On 2011-12-17 14:42:10 +0100, Luca Barbato wrote:
> Do not assume the audio packets being always smaller than
> DEFAULT_PES_PAYLOAD_SIZE.
> ---
> libavformat/mpegtsenc.c | 12 ++++++++----
> 1 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index 57cfe45..f38a83a 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -999,14 +999,18 @@ static int mpegts_write_packet(AVFormatContext *s,
> AVPacket *pkt)
> }
> }
>
> - if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO) {
> - // for video and subtitle, write a single pes packet
> - mpegts_write_pes(s, st, buf, size, pts, dts, pkt->flags &
> AV_PKT_FLAG_KEY);
> + // write a pes packet at least big DEFAULT_PES_PAYLOAD_SIZE
> + // for video and subtitle, write a single pes packet
> +
> + if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO ||
> + size > DEFAULT_PES_PAYLOAD_SIZE) {
> + mpegts_write_pes(s, st, buf, size, pts, dts,
> + pkt->flags & AV_PKT_FLAG_KEY);
> av_free(data);
> return 0;
> }
>
> - if (ts_st->payload_size + size > DEFAULT_PES_PAYLOAD_SIZE) {
> + if (ts_st->payload_size > DEFAULT_PES_PAYLOAD_SIZE) {
> mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_size,
> ts_st->payload_pts, ts_st->payload_dts,
> ts_st->payload_flags & AV_PKT_FLAG_KEY);
This will result in out of order audio data if the audio buffer is
occasionally smaller than DEFAULT_PES_PAYLOAD_SIZE.
Janne
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel