我想解锁使用FFMPEG库的android应用程序中的视频。一切工作正常。但是当我尝试从c代码创建一个文件来写入文件fopen中的不同流返回NULL。那之后我无法继续。我的代码是从原生c代码创建一个文件android
int ret , got_frame;
av_register_all();
LOGE("Registered formats");
err = av_open_input_file(&pFormatCtx, "file:/mnt/sdcard/input.mp4", NULL, 0, NULL);
LOGE("Called open file");
if(err!=0) {
LOGE("Couldn't open file");
return;
}
LOGE("Opened file");
if(av_find_stream_info(pFormatCtx)<0) {
LOGE("Unable to get stream info");
return;
}
videoStream = -1;
audioStream = -1;
for (i=0; i<pFormatCtx->nb_streams; i++) {
if(pFormatCtx->streams[i]->codec->codec_type==CODEC_TYPE_VIDEO) {
videoStream = i;
if(audioStream != -1)
break;
}
if(pFormatCtx->streams[i]->codec->codec_type==CODEC_TYPE_AUDIO) {
audioStream = i;
if(videoStream != -1)
break;
}
}
if(videoStream==-1) {
LOGE("Unable to find video stream");
return;
}
if(audioStream==-1) {
LOGE("Unable to find audio stream");
return;
}
LOGI("Video stream is [%d] Audio stream [%d]", videoStream,audioStream);
pCodecCtx=pFormatCtx->streams[videoStream]->codec;
pCodecCtxAudio=pFormatCtx->streams[audioStream]->codec;
LOGI("Video size is [%d x %d]", pCodecCtx->width, pCodecCtx->height);
videoOut = fopen("file:/mnt/sdcard/videoout.mp4","wb");
if (videoOut == NULL) {
LOGE("Unable to open output video");
return;
}
我的代码有什么问题。我为应用程序启用了在外部存储中写入的权限。我指定的路径也是正确的。帮我。
后logcat输出。 – Squonk