Exemplo n.º 1
0
// Human-readable AVFormat version
char const * human_readable_version() {
	static char version[256];
	snprintf(&version[0], sizeof(version), "%d.%d.%d", (avformat_version() >> 16) & 0xffff,
													   (avformat_version() >>  8) & 0x00ff,
													   (avformat_version()      ) & 0x00ff);
	return version;
}
Exemplo n.º 2
0
// LibAvW_Init
DLL_EXPORT int LibAvW_Init(avwCallbackPrint *printfunction)
{
	if (libav_initialized)
		return LIBAVW_ERROR_NONE;

	libav_codec_version  = avcodec_version();
	libav_format_version = avformat_version();
	libav_util_version   = avutil_version();
	libav_swscale_version  = swscale_version();

	// only can use version we were linked against
	if (libav_codec_version != LIBAVCODEC_VERSION_INT)
		return LIBAVW_ERROR_DLL_VERSION_AVCODEC;
	if (libav_format_version != LIBAVFORMAT_VERSION_INT)
		return LIBAVW_ERROR_DLL_VERSION_AVFORMAT;
	if (libav_util_version != LIBAVUTIL_VERSION_INT)
		return LIBAVW_ERROR_DLL_VERSION_AVUTIL;
	if (libav_swscale_version != LIBSWSCALE_VERSION_INT)
		return LIBAVW_ERROR_DLL_VERSION_SWSCALE;

	// allright, init libavcodec
	avcodec_register_all();
	av_register_all();
	av_log_set_callback(LibAvW_ErrorCallback);
	libav_initialized = true;
	libav_print = printfunction;
	return LIBAVW_ERROR_NONE;
}
Exemplo n.º 3
0
Arquivo: av_log.c Projeto: kax4/mpv
void print_libav_versions(void)
{
    print_version("libavutil", LIBAVUTIL_VERSION_INT, avutil_version());
    print_version("libavcodec", LIBAVCODEC_VERSION_INT, avcodec_version());
    print_version("libavformat", LIBAVFORMAT_VERSION_INT, avformat_version());
    print_version("libswscale", LIBSWSCALE_VERSION_INT, swscale_version());
}
Exemplo n.º 4
0
Arquivo: av_log.c Projeto: wiiaboo/mpv
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;
}
	ADM_MUXER_PLUGIN_EXPORT const char* getUnderlyingLibraryVersion()
	{
		if (version == NULL)
		{
			version = new char[10];
			snprintf(version, 10, "%d", avformat_version());
		}

		return version;
	}
Exemplo n.º 6
0
Arquivo: av_log.c Projeto: Bl4Cc4t/mpv
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);
    }
}
Exemplo n.º 7
0
/*
static void dump_stream_format(AVFormatContext *ic, int i, int index, int is_output)
{
	char buf[256];
	int flags = (is_output ? ic->oformat->flags : ic->iformat->flags);
	AVStream *st = ic->streams[i];
	int g = av_gcd(st->time_base.num, st->time_base.den);
	AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
	avcodec_string(buf, sizeof(buf), st->codec, is_output);
	av_log(NULL, AV_LOG_INFO, "    Stream #%d.%d", index, i);
	// the pid is an important information, so we display it
	// XXX: add a generic system
	if (flags & AVFMT_SHOW_IDS)
		av_log(NULL, AV_LOG_INFO, "[0x%x]", st->id);
	if (lang)
		av_log(NULL, AV_LOG_INFO, "(%s)", lang->value);
	av_log(NULL, AV_LOG_DEBUG, ", %d, %d/%d", st->codec_info_nb_frames, st->time_base.num/g, st->time_base.den/g);
	av_log(NULL, AV_LOG_INFO, ": %s", buf);
	if (st->sample_aspect_ratio.num && // default
		av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio)) {
		AVRational display_aspect_ratio;
		av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
				  st->codec->width*st->sample_aspect_ratio.num,
				  st->codec->height*st->sample_aspect_ratio.den,
				  1024*1024);
		av_log(NULL, AV_LOG_INFO, ", PAR %d:%d DAR %d:%d",
				 st->sample_aspect_ratio.num, st->sample_aspect_ratio.den,
				 display_aspect_ratio.num, display_aspect_ratio.den);
	}
	if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){
		if(st->avg_frame_rate.den && st->avg_frame_rate.num)
			print_fps(av_q2d(st->avg_frame_rate), "fps");
		if(st->r_frame_rate.den && st->r_frame_rate.num)
			print_fps(av_q2d(st->r_frame_rate), "tbr");
		if(st->time_base.den && st->time_base.num)
			print_fps(1/av_q2d(st->time_base), "tbn");
		if(st->codec->time_base.den && st->codec->time_base.num)
			print_fps(1/av_q2d(st->codec->time_base), "tbc");
	}
	if (st->disposition & AV_DISPOSITION_DEFAULT)
		av_log(NULL, AV_LOG_INFO, " (default)");
	if (st->disposition & AV_DISPOSITION_DUB)
		av_log(NULL, AV_LOG_INFO, " (dub)");
	if (st->disposition & AV_DISPOSITION_ORIGINAL)
		av_log(NULL, AV_LOG_INFO, " (original)");
	if (st->disposition & AV_DISPOSITION_COMMENT)
		av_log(NULL, AV_LOG_INFO, " (comment)");
	if (st->disposition & AV_DISPOSITION_LYRICS)
		av_log(NULL, AV_LOG_INFO, " (lyrics)");
	if (st->disposition & AV_DISPOSITION_KARAOKE)
		av_log(NULL, AV_LOG_INFO, " (karaoke)");
	if (st->disposition & AV_DISPOSITION_FORCED)
		av_log(NULL, AV_LOG_INFO, " (forced)");
	if (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED)
		av_log(NULL, AV_LOG_INFO, " (hearing impaired)");
	if (st->disposition & AV_DISPOSITION_VISUAL_IMPAIRED)
		av_log(NULL, AV_LOG_INFO, " (visual impaired)");
	if (st->disposition & AV_DISPOSITION_CLEAN_EFFECTS)
		av_log(NULL, AV_LOG_INFO, " (clean effects)");
	av_log(NULL, AV_LOG_INFO, "\n");
	dump_metadata(NULL, st->metadata, "    ");
}*/
void AVInfo::dump()
{
	qDebug("Version\n"
		   "libavcodec: %#x\n"
		   "libavformat: %#x\n"
//	       "libavdevice: %#x\n"
		   "libavutil: %#x"
		   ,avcodec_version()
		   ,avformat_version()
//	       ,avdevice_version()
		   ,avutil_version());
	av_dump_format(_format_context, 0, qPrintable(_file_name), false);
	qDebug("video format: %s [%s]", qPrintable(videoFormatName()), qPrintable(videoFormatLongName()));
	qDebug("Audio: %s [%s]", qPrintable(audioCodecName()), qPrintable(audioCodecLongName()));
	qDebug("sample rate: %d, channels: %d", a_codec_context->sample_rate, a_codec_context->channels);
}
Exemplo n.º 8
0
FFMS_Index::FFMS_Index(const char *IndexFile)
: RefCount(1)
{
	ZipFile zf(IndexFile, "rb");

	// Read the index file header
	if (zf.Read<uint32_t>() != INDEXID)
		throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_FILE_READ,
			std::string("'") + IndexFile + "' is not a valid index file");

	if (zf.Read<uint32_t>() != FFMS_VERSION)
		throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_FILE_READ,
			std::string("'") + IndexFile + "' is not the expected index version");

	uint32_t Tracks = zf.Read<uint32_t>();
	Decoder = zf.Read<uint32_t>();
	ErrorHandling = zf.Read<uint32_t>();

	if (!(Decoder & FFMS_GetEnabledSources()))
		throw FFMS_Exception(FFMS_ERROR_INDEX, FFMS_ERROR_NOT_AVAILABLE,
			"The source which this index was created with is not available");

	if (zf.Read<uint32_t>() != avutil_version() ||
		zf.Read<uint32_t>() != avformat_version() ||
		zf.Read<uint32_t>() != avcodec_version() ||
		zf.Read<uint32_t>() != swscale_version())
		throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_FILE_READ,
			std::string("A different FFmpeg build was used to create '") + IndexFile + "'");

	Filesize = zf.Read<int64_t>();
	zf.Read(Digest, sizeof(Digest));

	reserve(Tracks);
	try {
		for (size_t i = 0; i < Tracks; ++i)
			push_back(FFMS_Track(zf));
	}
	catch (FFMS_Exception const&) {
		throw;
	}
	catch (...) {
		throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_FILE_READ,
			std::string("Unknown error while reading index information in '") + IndexFile + "'");
	}
}
Exemplo n.º 9
0
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);
}
Exemplo n.º 10
0
void FFMS_Index::WriteIndex(const char *IndexFile) {
	ZipFile zf(IndexFile, "wb");

	// Write the index file header
	zf.Write<uint32_t>(INDEXID);
	zf.Write<uint32_t>(FFMS_VERSION);
	zf.Write<uint32_t>(size());
	zf.Write<uint32_t>(Decoder);
	zf.Write<uint32_t>(ErrorHandling);
	zf.Write<uint32_t>(avutil_version());
	zf.Write<uint32_t>(avformat_version());
	zf.Write<uint32_t>(avcodec_version());
	zf.Write<uint32_t>(swscale_version());
	zf.Write<int64_t>(Filesize);
	zf.Write(Digest);

	for (size_t i = 0; i < size(); ++i)
		at(i).Write(zf);

	zf.Finish();
}
Exemplo n.º 11
0
SoundSource::OpenResult SoundSourceFFmpeg::tryOpen(const AudioSourceConfig& /*audioSrcCfg*/) {
    AVDictionary *l_iFormatOpts = nullptr;

    const QString localFileName(getLocalFileName());
    qDebug() << "New SoundSourceFFmpeg :" << localFileName;

    DEBUG_ASSERT(!m_pFormatCtx);
    m_pFormatCtx = avformat_alloc_context();

    if (m_pFormatCtx == nullptr) {
        qDebug() << "SoundSourceFFmpeg::tryOpen: Can't allocate memory";
        return OpenResult::FAILED;
    }

    // TODO() why is this required, should't it be a runtime check
#if LIBAVCODEC_VERSION_INT < 3622144 // 55.69.0
    m_pFormatCtx->max_analyze_duration = 999999999;
#endif

    // libav replaces open() with ff_win32_open() which accepts a
    // Utf8 path
    // see: avformat/os_support.h
    // The old method defining an URL_PROTOCOL is deprecated
#if defined(_WIN32) && !defined(__MINGW32CE__)
    const QByteArray qBAFilename(
            avformat_version() >= ((52<<16)+(0<<8)+0) ?
            getLocalFileName().toUtf8() :
            getLocalFileName().toLocal8Bit());
#else
    const QByteArray qBAFilename(getLocalFileName().toLocal8Bit());
#endif

    // Open file and make m_pFormatCtx
    if (avformat_open_input(&m_pFormatCtx, qBAFilename.constData(), nullptr,
                            &l_iFormatOpts) != 0) {
        qDebug() << "SoundSourceFFmpeg::tryOpen: cannot open" << localFileName;
        return OpenResult::FAILED;
    }

    // TODO() why is this required, should't it be a runtime check
#if LIBAVCODEC_VERSION_INT > 3544932 // 54.23.100
    av_dict_free(&l_iFormatOpts);
#endif

    // Retrieve stream information
    if (avformat_find_stream_info(m_pFormatCtx, nullptr) < 0) {
        qDebug() << "SoundSourceFFmpeg::tryOpen: cannot open" << localFileName;
        return OpenResult::FAILED;
    }

    //debug only (Enable if needed)
    //av_dump_format(m_pFormatCtx, 0, qBAFilename.constData(), false);

    // Find the first audio stream
    m_iAudioStream = -1;

    for (unsigned int i = 0; i < m_pFormatCtx->nb_streams; i++)
        if (m_pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
            m_iAudioStream = i;
            break;
        }

    if (m_iAudioStream == -1) {
        qDebug() <<
                 "SoundSourceFFmpeg::tryOpen: cannot find an audio stream: cannot open"
                 << localFileName;
        return OpenResult::FAILED;
    }

    // Get a pointer to the codec context for the audio stream
    m_pCodecCtx = m_pFormatCtx->streams[m_iAudioStream]->codec;

    // Find the decoder for the audio stream
    if (!(m_pCodec = avcodec_find_decoder(m_pCodecCtx->codec_id))) {
        qDebug() << "SoundSourceFFmpeg::tryOpen: cannot find a decoder for" <<
                localFileName;
        return OpenResult::UNSUPPORTED_FORMAT;
    }

    if (avcodec_open2(m_pCodecCtx, m_pCodec, nullptr)<0) {
        qDebug() << "SoundSourceFFmpeg::tryOpen: cannot open" << localFileName;
        return OpenResult::FAILED;
    }

    m_pResample = std::make_unique<EncoderFfmpegResample>(m_pCodecCtx);
    m_pResample->openMixxx(m_pCodecCtx->sample_fmt, AV_SAMPLE_FMT_FLT);

    setChannelCount(m_pCodecCtx->channels);
    setSamplingRate(m_pCodecCtx->sample_rate);
    setFrameCount((qint64)round((double)((double)m_pFormatCtx->duration *
                                         (double)m_pCodecCtx->sample_rate) / (double)AV_TIME_BASE));

    qDebug() << "SoundSourceFFmpeg::tryOpen: Sampling rate: " << getSamplingRate() <<
             ", Channels: " <<
             getChannelCount() << "\n";
    if (getChannelCount() > 2) {
        qDebug() << "ffmpeg: No support for more than 2 channels!";
        return OpenResult::FAILED;
    }

    return OpenResult::SUCCEEDED;
}
Exemplo n.º 12
0
ExportFFmpeg::ExportFFmpeg()
:  ExportPlugin()
{
   mEncFormatCtx = NULL;       // libavformat's context for our output file
   mEncFormatDesc = NULL;      // describes our output file to libavformat
   mEncAudioStream = NULL;     // the output audio stream (may remain NULL)
   mEncAudioCodecCtx = NULL;   // the encoder for the output audio stream
   #define MAX_AUDIO_PACKET_SIZE (128 * 1024)
   mEncAudioFifoOutBuf = NULL; // buffer to read _out_ of the FIFO into
   mEncAudioFifoOutBufSiz = 0;

   mSampleRate = 0;
   mSupportsUTF8 = true;

   PickFFmpegLibs(); // DropFFmpegLibs() call is in ExportFFmpeg::Destroy()
   int avfver = FFmpegLibsInst->ValidLibsLoaded() ? avformat_version() : 0;
   int newfmt;
   // Adds export types from the export type list
   for (newfmt = 0; newfmt < FMT_LAST; newfmt++)
   {
      wxString shortname(ExportFFmpegOptions::fmts[newfmt].shortname);
      //Don't hide export types when there's no av-libs, and don't hide FMT_OTHER
      if (newfmt < FMT_OTHER && FFmpegLibsInst->ValidLibsLoaded())
      {
         // Format/Codec support is compiled in?
         AVOutputFormat *avoformat = av_guess_format(shortname.mb_str(), NULL, NULL);
         AVCodec *avcodec = avcodec_find_encoder(ExportFFmpegOptions::fmts[newfmt].codecid);
         if (avoformat == NULL || avcodec == NULL)
         {
            ExportFFmpegOptions::fmts[newfmt].compiledIn = false;
            continue;
         }
      }
      int fmtindex = AddFormat() - 1;
      SetFormat(ExportFFmpegOptions::fmts[newfmt].name,fmtindex);
      AddExtension(ExportFFmpegOptions::fmts[newfmt].extension,fmtindex);
      // For some types add other extensions
      switch(newfmt)
      {
      case FMT_M4A:
         AddExtension(wxString(wxT("3gp")),fmtindex);
         AddExtension(wxString(wxT("m4r")),fmtindex);
         AddExtension(wxString(wxT("mp4")),fmtindex);
         break;
      case FMT_WMA2:
         AddExtension(wxString(wxT("asf")),fmtindex);
         AddExtension(wxString(wxT("wmv")),fmtindex);
         break;
      default:
         break;
      }

      SetMaxChannels(ExportFFmpegOptions::fmts[newfmt].maxchannels,fmtindex);
      SetDescription(ExportFFmpegOptions::fmts[newfmt].description,fmtindex);

      int canmeta = ExportFFmpegOptions::fmts[newfmt].canmetadata;
      if (canmeta && (canmeta == AV_VERSION_INT(-1,-1,-1) || canmeta <= avfver))
      {
         SetCanMetaData(true,fmtindex);
      }
      else
      {
         SetCanMetaData(false,fmtindex);
      }
   }
}