0
큰 문제를 해결하려고하지만 아주 작은 문제가 있습니다. ffmpeg의 도움으로 비디오 파일 안의 오디오 스트림을 읽으려고하지만 스트림의 전체 파일을 탐색해야하는 루프는 몇 번만 실행됩니다. 다른 사람들이 그것을 매우 비슷하게 사용함에 따라 문제가 무엇인지 파악할 수 없습니다. 당신이 라이브러리 로딩 및 언 로딩하는 방법과 그 JNI를 통해 호출을 반복 관련에 관련된 문제가 발생 될 수 있습니다ffmpeg로 오디오 스트림을 읽을 수 없습니다.
JNIEXPORT jint JNICALL Java_ru_dzakhov_ffmpeg_test_MainActivity_logFileInfo
(JNIEnv * env,
jobject this,
jstring filename
)
{
AVFormatContext *pFormatCtx;
int i,j,k, videoStream, audioStream;
AVCodecContext *pCodecCtx;
AVCodec *pCodec;
AVFrame *pFrame;
AVPacket packet;
int frameFinished;
float aspect_ratio;
AVCodecContext *aCodecCtx;
AVCodec *aCodec;
//uint8_t inbuf[AUDIO_INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
j=0;
av_register_all();
char *str = (*env)->GetStringUTFChars(env, filename, 0);
LOGI(str);
// Open video file
if(av_open_input_file(&pFormatCtx, str, NULL, 0, NULL)!=0)
;
// Retrieve stream information
if(av_find_stream_info(pFormatCtx)<0)
;
LOGI("Separating");
// Find the first video stream
videoStream=-1;
audioStream=-1;
for(i=0; i<&pFormatCtx->nb_streams; i++) {
if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO)
{
LOGI("Audio Stream");
audioStream=i;
}
}
av_write_header(pFormatCtx);
if(videoStream==-1)
LOGI("Video stream is -1");
if(audioStream==-1)
LOGI("Audio stream is -1");
return i;}