72 lines
2.3 KiB
Diff
72 lines
2.3 KiB
Diff
--- a/src/modules/mod_libavcodec/trgt_av.cpp 2022-10-25 09:14:12.000000000 -0400
|
|
+++ b/src/modules/mod_libavcodec/trgt_av.cpp 2023-05-05 21:34:17.899194559 -0400
|
|
@@ -38,6 +41,7 @@
|
|
extern "C"
|
|
{
|
|
#ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
|
|
+# include <libavcodec/avcodec.h>
|
|
# include <libavformat/avformat.h>
|
|
#elif defined(HAVE_AVFORMAT_H)
|
|
# include <avformat.h>
|
|
@@ -155,11 +156,11 @@
|
|
}
|
|
|
|
bool open_video_stream() {
|
|
- if (avcodec_open2(video_context, NULL, NULL) < 0) {
|
|
+ if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
|
|
synfig::error("Target_LibAVCodec: could not open video codec");
|
|
// seems the calling of avcodec_free_context after error will cause crash
|
|
// so just forget about this context
|
|
- video_context = NULL;
|
|
+ video_context = nullptr;
|
|
close();
|
|
return false;
|
|
}
|
|
@@ -234,15 +235,21 @@
|
|
close();
|
|
|
|
if (!av_registered) {
|
|
+#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
|
|
av_register_all();
|
|
+#endif
|
|
av_registered = true;
|
|
}
|
|
|
|
// guess format
|
|
- AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
|
|
+#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
|
|
+ AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
|
|
+#else
|
|
+ const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
|
|
+#endif
|
|
if (!format) {
|
|
synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
|
|
- format = av_guess_format("mpeg", NULL, NULL);
|
|
+ format = av_guess_format("mpeg", nullptr, nullptr);
|
|
}
|
|
if (!format) {
|
|
synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
|
|
@@ -254,6 +261,7 @@
|
|
context = avformat_alloc_context();
|
|
assert(context);
|
|
context->oformat = format;
|
|
+#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
|
|
if (filename.size() + 1 > sizeof(context->filename)) {
|
|
synfig::error(
|
|
"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
|
|
@@ -263,6 +271,14 @@
|
|
return false;
|
|
}
|
|
memcpy(context->filename, filename.c_str(), filename.size() + 1);
|
|
+#else
|
|
+ context->url = av_strndup(filename.c_str(), filename.size());
|
|
+ if (!context->url) {
|
|
+ synfig::error("Target_LibAVCodec: cannot allocate space for filename");
|
|
+ close();
|
|
+ return false;
|
|
+ }
|
|
+#endif
|
|
|
|
packet = av_packet_alloc();
|
|
assert(packet);
|