Jelajahi Sumber

libobs/media-io: Add ifdef for newer FFmpeg functions

The AVCodecParameters weren't introduced until avcodec version 57.48.101
(FFmpeg version 3.1), so this will make sure to still use the older
avcodec_copy_context if the detected FFmpeg version is earlier.
jp9000 7 tahun lalu
induk
melakukan
3114a240b4
1 mengubah file dengan 4 tambahan dan 0 penghapusan
  1. 4 0
      libobs/media-io/media-remux.c

+ 4 - 0
libobs/media-io/media-remux.c

@@ -92,12 +92,16 @@ static inline bool init_output(media_remux_job_t job, const char *out_filename)
 			return false;
 		}
 
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 48, 101)
 		AVCodecParameters *par = avcodec_parameters_alloc();
 		ret = avcodec_parameters_from_context(par, in_stream->codec);
 		if (ret == 0)
 			ret = avcodec_parameters_to_context(out_stream->codec,
 					par);
 		avcodec_parameters_free(&par);
+#else
+		ret = avcodec_copy_context(out_stream->codec, in_stream->codec);
+#endif
 
 		if (ret < 0) {
 			blog(LOG_ERROR, "media_remux: Failed to copy context");