ffmpeg 4.0.2中缺少许多编解码器,该怎么办?

时间:2018-10-22 11:25:16

标签: android ffmpeg android-ffmpeg

我最近使用本教程的教程将ffmpeg 4.0.2构建为共享库,以便将其包含在android项目中:enter link description here

构建成功,但是我的库缺少msvideo1,xanwc4,...等几种编解码器。

我检查了ffmpeg4.0.2文件夹中libavcodec文件夹中的c文件找不到很多编解码器格式。 例如,libavcodec文件夹包含名为xan.c的文件,该文件包含xan,xanwc3的功能,但不包含xanwc4的功能。 但是在libvcodec / xxan.c中发现xanwc4编解码器,但avcodec_open2()仍返回-22。 每个编解码器avcodec_open2()返回-22。

有人可以帮助我弄清楚如何使我的.apk在每种编解码器和格式上都能工作吗?如何处理丢失的编解码器?

c源代码在这里:

const char *name;
int i,videostream;
name= (*env)->GetStringUTFChars(env, argv_,0);
AVFormatContext *pFormatctx=NULL;
if (avformat_open_input(&pFormatctx,name,NULL,NULL)!=0){
    return (*env)->NewStringUTF(env,"a");
}
if(pFormatctx==NULL){
    return (*env)->NewStringUTF(env,"b");
}
if(avformat_find_stream_info(pFormatctx,NULL)<0){
    return (*env)->NewStringUTF(env,"c");
}
av_dump_format(pFormatctx, 0, name, 0);
videostream=-1;
AVCodecContext *pCodecCtxOrig = NULL;
AVCodecContext *pCodecCtx = NULL;
for (i==0;i<pFormatctx->nb_streams;i++){
    if((pFormatctx->streams[i]->codecpar->codec_type)==AVMEDIA_TYPE_VIDEO){
        videostream=i;
        break;
    }
}
if(videostream==-1){
    return (*env)->NewStringUTF(env,"d");
}
pCodecCtxOrig=pFormatctx->streams[videostream]->codecpar;
AVCodec *pCodec = NULL;
pCodec=avcodec_find_decoder(pCodecCtxOrig->codec_id);
if(pCodec==NULL){
    return (*env)->NewStringUTF(env,"e");
}
pCodecCtx=avcodec_alloc_context3(pCodec);
if((avcodec_parameters_to_context(pCodecCtx,pCodecCtxOrig))!=0){
    return (*env)->NewStringUTF(env,"f");
}
if(avcodec_open2(pCodecCtx,pCodec,NULL)<0){
    return (*env)->NewStringUTF(env,"g");
}

0 个答案:

没有答案