]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
update to ffmpeg codecpar
authoralingherghescu <alin_gherghescu@yahoo.com>
Tue, 21 Mar 2023 16:52:40 +0000 (09:52 -0700)
committerFlole998 <Flole998@users.noreply.github.com>
Thu, 23 Mar 2023 02:23:04 +0000 (03:23 +0100)
- update to ffmpeg codecpar

src/input/mpegts/iptv/iptv_libav.c

index 99c76379151ffc744bfd242a2cf9e06c2bf15977..8e328872745ef81a88df24d2f8a851a5f3d795a0 100644 (file)
@@ -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);