KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I tried to decode video using FFMpeg library from the sample examples available on internet, i figure it out with new version of ffmpeg, here is the code which I called from my class file, private static native int decodeVideo(String filename); decodeVideo(getString(R.string._sdcard_abc_3gp)); now in .c file located in JNI dir,I wrote this code, jint Java_ru_dzakhov_ffmpeg_test_MainActivity_decodeVideo(JNIEnv* env, jobject javaThis,jstring filename) { AVFormatContext *pFormatCtx; int i, videoStream; AVCodecContext *pCodecCtx; AVCodec *pCodec; AVFrame *pFrame; AVFrame *pFrameRGB; AVPacket packet; int frameFinished; int numBytes; uint8_t *buffer; // Register all formats and codecs av_register_all(); // Open video file const jbyte *str; str = (*env)->GetStringUTFChars(env, filename, NULL); if(av_open_input_file(&pFormatCtx, str, NULL, 0, NULL)!=0) { LOGI("Can't open file '%s'\n", str); return 1; } else { LOGI("File is opened\n"); LOGI("File '%s', Codec %s",pFormatCtx->filename,pFormatCtx->iformat->name); } // Dump information about file onto standard error LOGI("dump_format"); dump_format(pFormatCtx, 0, filename, 0); LOGI("dump_format DONE"); // Find the first video stream videoStream=-1; for(i=0; i<pFormatCtx->nb_streams; i++) if(pFormatCtx->streams[i]->codec->codec_type==CODEC_TYPE_VIDEO) //if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO) { LOGI("videoStream:: %d",videoStream); videoStream=i; break; } if(videoStream==-1) return -1; // Didn't find a video stream // Get a pointer to the codec context for the video stream pCodecCtx=pFormatCtx->streams[videoStream]->codec; // Find the
Tags (comma-separated)
Save Edits
Cancel