From: alingherghescu Date: Tue, 21 Mar 2023 16:52:40 +0000 (-0700) Subject: update to ffmpeg codecpar X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=933ae5f767ea4ddd08656f59b8cc973756b59342;p=thirdparty%2Ftvheadend.git update to ffmpeg codecpar - update to ffmpeg codecpar --- diff --git a/src/input/mpegts/iptv/iptv_libav.c b/src/input/mpegts/iptv/iptv_libav.c index 99c763791..8e3288727 100644 --- a/src/input/mpegts/iptv/iptv_libav.c +++ b/src/input/mpegts/iptv/iptv_libav.c @@ -87,6 +87,8 @@ iptv_libav_thread(void *aux) iptv_libav_priv_t *la = aux; AVStream *in_stream, *out_stream; AVPacket pkt; + AVCodecContext *c; + const AVCodec *codec; uint8_t *buf = NULL; int ret, i; @@ -115,19 +117,24 @@ iptv_libav_thread(void *aux) for (i = 0; i < la->ictx->nb_streams; i++) { in_stream = la->ictx->streams[i]; - out_stream = avformat_new_stream(la->octx, in_stream->codec->codec); + codec = avcodec_find_encoder(in_stream->codecpar->codec_id); + c = avcodec_alloc_context3(codec); + out_stream = avformat_new_stream(la->octx, codec); if (out_stream == NULL) { tvherror(LS_IPTV, "libav: Failed allocating output stream"); + avcodec_free_context(&c); goto fail; } ret = avcodec_parameters_copy(out_stream->codecpar, in_stream->codecpar); if (ret < 0) { tvherror(LS_IPTV, "libav: Failed to copy context from input to output stream codec context: %s", av_err2str(ret)); + avcodec_free_context(&c); goto fail; } - out_stream->codec->codec_tag = 0; + out_stream->codecpar->codec_tag = 0; if (la->octx->oformat->flags & AVFMT_GLOBALHEADER) - out_stream->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; + c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; + avcodec_free_context(&c); } ret = avformat_write_header(la->octx, NULL);