diff --git a/libavformat/rtpenc_mpegts.c b/libavformat/rtpenc_mpegts.c index 4e243f0bd8..f170f97934 100644 --- a/libavformat/rtpenc_mpegts.c +++ b/libavformat/rtpenc_mpegts.c @@ -32,11 +32,9 @@ static int rtp_mpegts_write_close(AVFormatContext *s) struct MuxChain *chain = s->priv_data; if (chain->mpegts_ctx) { - if (!chain->mpegts_ctx->pb) - avio_open_dyn_buf(&chain->mpegts_ctx->pb); + av_write_trailer(chain->mpegts_ctx); if (chain->mpegts_ctx->pb) { uint8_t *buf; - av_write_trailer(chain->mpegts_ctx); avio_close_dyn_buf(chain->mpegts_ctx->pb, &buf); av_free(buf); }