bool print_libav_versions(struct mp_log *log, int v) { const struct lib libs[] = { {"libavutil", LIBAVUTIL_VERSION_INT, avutil_version()}, {"libavcodec", LIBAVCODEC_VERSION_INT, avcodec_version()}, {"libavformat", LIBAVFORMAT_VERSION_INT, avformat_version()}, {"libswscale", LIBSWSCALE_VERSION_INT, swscale_version()}, {"libavfilter", LIBAVFILTER_VERSION_INT, avfilter_version()}, #if HAVE_LIBAV {"libavresample", LIBAVRESAMPLE_VERSION_INT, avresample_version()}, #else {"libswresample", LIBSWRESAMPLE_VERSION_INT, swresample_version()}, #endif }; mp_msg(log, v, "%s library versions:\n", LIB_PREFIX); bool mismatch = false; for (int n = 0; n < MP_ARRAY_SIZE(libs); n++) { const struct lib *l = &libs[n]; mp_msg(log, v, " %-15s %d.%d.%d", l->name, V(l->buildv)); if (l->buildv != l->runv) { mp_msg(log, v, " (runtime %d.%d.%d)", V(l->runv)); mismatch = true; } mp_msg(log, v, "\n"); } mp_msg(log, v, "%s version: %s\n", LIB_PREFIX, av_version_info()); return !mismatch; }
void print_libav_versions(struct mp_log *log, int v) { const struct lib libs[] = { {"libavutil", LIBAVUTIL_VERSION_INT, avutil_version()}, {"libavcodec", LIBAVCODEC_VERSION_INT, avcodec_version()}, {"libavformat", LIBAVFORMAT_VERSION_INT, avformat_version()}, {"libswscale", LIBSWSCALE_VERSION_INT, swscale_version()}, #if HAVE_LIBAVFILTER {"libavfilter", LIBAVFILTER_VERSION_INT, avfilter_version()}, #endif #if HAVE_LIBAVRESAMPLE {"libavresample", LIBAVRESAMPLE_VERSION_INT, avresample_version()}, #endif #if HAVE_LIBSWRESAMPLE {"libswresample", LIBSWRESAMPLE_VERSION_INT, swresample_version()}, #endif }; mp_msg(log, v, "%s library versions:\n", LIB_PREFIX); bool mismatch = false; bool broken = false; for (int n = 0; n < MP_ARRAY_SIZE(libs); n++) { const struct lib *l = &libs[n]; mp_msg(log, v, " %-15s %d.%d.%d", l->name, V(l->buildv)); if (l->buildv != l->runv) { mp_msg(log, v, " (runtime %d.%d.%d)", V(l->runv)); mismatch = true; broken |= ((l->buildv & 255) >= 100) != ((l->runv & 255) >= 100); } mp_msg(log, v, "\n"); } // This just won't work. It's 100% broken. if (broken) { mp_fatal(log, "mpv was compiled and linked against a mixture of Libav " "and FFmpeg versions. This won't work and will most likely " "crash at some point. Exiting.\n"); exit(42); } // We don't "really" support mismatched libraries, but if you like to // suffer, you're free to enjoy the terrible aspects of dynamic linking. // In particular, we don't use all these crazy accessors ffmpeg wants us // to use in order to be ABI compatible after Libav merges - because that // would make our code incompatible to Libav. It's madness. if (mismatch) { mp_warn(log, "Warning: mpv was compiled against a different version of " "%s than the shared\nlibrary it is linked against. This can " "expose subtle ABI compatibility issues\nand can lead to " "misbehavior and crashes.\n", LIB_PREFIX); } }
void ffmpeg_version_print() { struct _component { const char* lib; unsigned build_version; unsigned rt_version; } components[] = { { "avcodec", LIBAVCODEC_VERSION_INT, avcodec_version()}, { "avformat", LIBAVFORMAT_VERSION_INT, avformat_version()}, { "avutil", LIBAVUTIL_VERSION_INT, avutil_version()}, { "swscale", LIBSWSCALE_VERSION_INT, swscale_version()}, #if QTAV_HAVE(SWRESAMPLE) { "swresample", LIBSWRESAMPLE_VERSION_INT, swresample_version()}, //swresample_version not declared in 0.9 #endif //QTAV_HAVE(SWRESAMPLE) #if QTAV_HAVE(AVRESAMPLE) { "avresample", LIBAVRESAMPLE_VERSION_INT, avresample_version()}, #endif //QTAV_HAVE(AVRESAMPLE) #if QTAV_HAVE(AVFILTER) { "avfilter", LIBAVFILTER_VERSION_INT, avfilter_version() }, #endif //QTAV_HAVE(AVFILTER) { 0, 0, 0} }; for (int i = 0; components[i].lib != 0; ++i) { printf("Build with lib%s-%u.%u.%u\n" , components[i].lib , QTAV_VERSION_MAJOR(components[i].build_version) , QTAV_VERSION_MINOR(components[i].build_version) , QTAV_VERSION_PATCH(components[i].build_version) ); unsigned rt_version = components[i].rt_version; if (components[i].build_version != rt_version) { fprintf(stderr, "Warning: %s runtime version %u.%u.%u mismatch!\n" , components[i].lib , QTAV_VERSION_MAJOR(rt_version) , QTAV_VERSION_MINOR(rt_version) , QTAV_VERSION_PATCH(rt_version) ); } } fflush(0); }