QTfrontend/util/LibavInteraction.cpp
changeset 8065 609d07b337b5
parent 7897 5e7c0810f365
child 8362 89a6b7cc6f95
equal deleted inserted replaced
8064:202e2cce7077 8065:609d07b337b5
    68     // initialize libav and register all codecs and formats
    68     // initialize libav and register all codecs and formats
    69     av_register_all();
    69     av_register_all();
    70 
    70 
    71     // get list of all codecs
    71     // get list of all codecs
    72     AVCodec* pCodec = NULL;
    72     AVCodec* pCodec = NULL;
    73     while (pCodec = av_codec_next(pCodec))
    73     while ((pCodec = av_codec_next(pCodec)))
    74     {
    74     {
    75 #if LIBAVCODEC_VERSION_MAJOR >= 54
    75 #if LIBAVCODEC_VERSION_MAJOR >= 54
    76         if (!av_codec_is_encoder(pCodec))
    76         if (!av_codec_is_encoder(pCodec))
    77 #else
    77 #else
    78         if (!pCodec->encode)
    78         if (!pCodec->encode)
   160         //codec.longName += QString(" (%1)").arg(codec.shortName);
   160         //codec.longName += QString(" (%1)").arg(codec.shortName);
   161     }
   161     }
   162 
   162 
   163     // get list of all formats
   163     // get list of all formats
   164     AVOutputFormat* pFormat = NULL;
   164     AVOutputFormat* pFormat = NULL;
   165     while (pFormat = av_oformat_next(pFormat))
   165     while ((pFormat = av_oformat_next(pFormat)))
   166     {
   166     {
   167         if (!pFormat->extensions)
   167         if (!pFormat->extensions)
   168             continue;
   168             continue;
   169 
   169 
   170         // skip some strange formats to not confuse users
   170         // skip some strange formats to not confuse users
   268 {
   268 {
   269     AVFormatContext* pContext = NULL;
   269     AVFormatContext* pContext = NULL;
   270     QByteArray utf8path = filepath.toUtf8();
   270     QByteArray utf8path = filepath.toUtf8();
   271     if (avformat_open_input(&pContext, utf8path.data(), NULL, NULL) < 0)
   271     if (avformat_open_input(&pContext, utf8path.data(), NULL, NULL) < 0)
   272         return "";
   272         return "";
   273 #if LIBAVFORMAT_VERSION_MAJOR < 54
   273 #if LIBAVFORMAT_VERSION_MAJOR < 53
   274     if (av_find_stream_info(pContext) < 0)
   274     if (av_find_stream_info(pContext) < 0)
   275 #else
   275 #else
   276     if (avformat_find_stream_info(pContext, NULL) < 0)
   276     if (avformat_find_stream_info(pContext, NULL) < 0)
   277 #endif
   277 #endif
   278         return "";
   278         return "";
   306         desc += "\n";
   306         desc += "\n";
   307     }
   307     }
   308     AVDictionaryEntry* pComment = av_dict_get(pContext->metadata, "comment", NULL, 0);
   308     AVDictionaryEntry* pComment = av_dict_get(pContext->metadata, "comment", NULL, 0);
   309     if (pComment)
   309     if (pComment)
   310         desc += QString("\n") + pComment->value;
   310         desc += QString("\n") + pComment->value;
   311 #if LIBAVFORMAT_VERSION_MAJOR < 54
   311 #if LIBAVFORMAT_VERSION_MAJOR < 53
   312     av_close_input_file(pContext);
   312     av_close_input_file(pContext);
   313 #else
   313 #else
   314     avformat_close_input(&pContext);
   314     avformat_close_input(&pContext);
   315 #endif
   315 #endif
   316     return desc;
   316     return desc;