diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index a32c6d6787..3b898da53b 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -1400,7 +1400,8 @@ static int mpegts_write_end(AVFormatContext *s) MpegTSService *service; int i; - mpegts_write_flush(s); + if (s->pb) + mpegts_write_flush(s); for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i];