[FFmpeg-devel] [PATCH] avformat/mpegtsenc: Always output a minimum of 32 packets.

Marton Balint cus at passwd.hu
Tue Nov 29 00:25:07 EET 2022



On Mon, 28 Nov 2022, James Almer wrote:

> From: Thierry Foucu <tfoucu at gmail.com>
>
> Otherwise, if you just output a PAT/PMT and a single TS packets, the
> demuxer will not be able to detect TS.

This looks like a demuxer bug, which should be fixed in the demuxer, and 
not in the muxer.

Regards,
Marton

>
> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
> libavformat/mpegtsenc.c | 11 ++++-------
> tests/ref/acodec/s302m  |  4 ++--
> tests/ref/lavf/ts       |  4 ++--
> 3 files changed, 8 insertions(+), 11 deletions(-)
>
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index 48d39e6a7d..760e5fd8c6 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -2147,8 +2147,7 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
>
> static void mpegts_write_flush(AVFormatContext *s)
> {
> -    MpegTSWrite *ts = s->priv_data;
> -    int i;
> +    int packets, i;
>
>     /* flush current packets */
>     for (i = 0; i < s->nb_streams; i++) {
> @@ -2163,11 +2162,9 @@ static void mpegts_write_flush(AVFormatContext *s)
>         }
>     }
>
> -    if (ts->m2ts_mode) {
> -        int packets = (avio_tell(s->pb) / (TS_PACKET_SIZE + 4)) % 32;
> -        while (packets++ < 32)
> -            mpegts_insert_null_packet(s);
> -    }
> +    packets = (avio_tell(s->pb) / (TS_PACKET_SIZE + 4)) % 32;
> +    while (packets++ < 32)
> +        mpegts_insert_null_packet(s);
> }
>
> static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
> diff --git a/tests/ref/acodec/s302m b/tests/ref/acodec/s302m
> index 2919ed6e55..5c12d5ff69 100644
> --- a/tests/ref/acodec/s302m
> +++ b/tests/ref/acodec/s302m
> @@ -1,4 +1,4 @@
> -0bf5457fd41a22fc5cdd99ae5ad4e273 *tests/data/fate/acodec-s302m.mpegts
> -1527688 tests/data/fate/acodec-s302m.mpegts
> +51fdac8dddb34b067f458b8114e3a32c *tests/data/fate/acodec-s302m.mpegts
> +1529944 tests/data/fate/acodec-s302m.mpegts
> 31f25a0020fd9017de9c3c608316854b *tests/data/fate/acodec-s302m.out.wav
> stddev:  986.94 PSNR: 36.44 MAXDIFF:18571 bytes:  1058400/  1056708
> diff --git a/tests/ref/lavf/ts b/tests/ref/lavf/ts
> index b004fc1b1c..cb5395abbc 100644
> --- a/tests/ref/lavf/ts
> +++ b/tests/ref/lavf/ts
> @@ -1,3 +1,3 @@
> -371dc016eb3155116bea27e3b4eeb928 *tests/data/lavf/lavf.ts
> -389160 tests/data/lavf/lavf.ts
> +cf342532317c4ae802c4f95f7d1f2459 *tests/data/lavf/lavf.ts
> +393296 tests/data/lavf/lavf.ts
> tests/data/lavf/lavf.ts CRC=0x71287e25
> -- 
> 2.38.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>


More information about the ffmpeg-devel mailing list