FFMS / ffms2

An FFmpeg based source library and Avisynth/VapourSynth plugin for easy frame accurate access
Other
582 stars 105 forks source link

FFMS_AudioSource is always NULL #218

Closed slajar closed 9 years ago

slajar commented 9 years ago

I found the latest ffms2 sdk and it can be used from vs2008 even it is compiled with 2015 :) Well, I build a very very small example (command line and 32 bit) to test the decoding qualities of ffms2. Actually, I get a VideoSource from an ordinary mp4 file. The AudioSource is always NULL and the ErrorInfo says: ErrorInfo {ErrorType=1 SubType=27 BufferSize=-858993460 ...} FFMS_ErrorInfo

AFAIK, error type 1 is something wrong with indexing and 27 is invalid parameter. Well, there are not much parameters. SrcFile works with Video, atrack is 1 (in my own ffmpeg tests it is also 1 for this file), FI is also working for VideoSource and I tried all three possibilities for the delay (FFMS_DELAY_NO_SHIFT, FFMS_DELAY_TIME_ZERO and FFMS_DELAY_FIRST_VIDEO_TRACK)

FFMS_Init(0, 1); FFMS_ErrorInfo ErrorInfo; FFMS_Indexer FIdx = FFMS_CreateIndexerWithDemuxer(SrcFile, FFMS_SOURCE_DEFAULT, &ErrorInfo); FFMS_SetAudioNameCallback(FIdx, GenAudioFilename, NULL); FFMS_SetProgressCallback(FIdx, UpdateProgress, &Progress); const char Name = FFMS_GetCodecNameI(FIdx, 0);

//FFMS_TrackTypeIndexSettings(FIdx, FFMS_TYPE_AUDIO, 1, -1);

FFMS_Index *FI = FFMS_DoIndexing2(FIdx, IgnoreErrors, &ErrorInfo);
int vtrack = FFMS_GetFirstTrackOfType(FI, FFMS_TYPE_VIDEO, &ErrorInfo);
int atrack = FFMS_GetFirstTrackOfType(FI, FFMS_TYPE_AUDIO, &ErrorInfo);
uint8_t *DB = new uint8_t[100000];
FFMS_VideoSource *V = FFMS_CreateVideoSource(SrcFile, vtrack, FI, 1, FFMS_SEEK_NORMAL, &ErrorInfo);

FFMS_AudioSource *A = FFMS_CreateAudioSource(SrcFile, atrack, FI, FFMS_DELAY_FIRST_VIDEO_TRACK, &ErrorInfo);

   ... here the problem occours ....

Any idea?

I tried also a MPG file, becuase I was not sure if the AAC decoder is enabled in your ffmpeg build. Same problem there.

slajar commented 9 years ago

I found now that no audiotrac is decoding. Even a plain wav file gives "Audio track contains no audio frames". It seems that libav is compiled without audio. May that be possible?

slajar commented 9 years ago

Well, I though it might be a bug in the new version and I went back to 2.20. Unfortunately, it is the same there. So, I am sure it must be an issue in my code.

slajar commented 9 years ago

Well, after hours of research I managed to compile version 2.20 on VS2008 :) After that I could debug through the code and I found that I needed to index much more to get audio buffers: This solved my initial problem:

FFMS_Index *FI = FFMS_DoIndexing(FIdx, -1, 0, GenAudioFilename, NULL, IgnoreErrors, UpdateProgress, &Progress, &ErrorInfo);

I am not sure if DoIndexing2 should do this also internally. "-1" was the solution for IndexMask.

myrsloik commented 9 years ago

This is documented behavior and something users of the avisynth plugin are also familiar with. It is this way because audio often causes issues and most users only want video. Not a bug.

slajar commented 9 years ago

Well, I don't see where it is documented https://github.com/FFMS/ffms2/blob/master/doc/ffms2-api.md#ffms_doindexing2---indexes-the-file-represented-by-an-indexer-object says nothing about that it is not intended to use for Audio.

myrsloik commented 9 years ago

https://github.com/FFMS/ffms2/blob/master/doc/ffms2-api.md#int-index

slajar commented 9 years ago

ohh, I see :)

quite offtopic, but I am not sure where to ask (is there a mailing list?). I ported libavresample to swresample with a preprocessor switch like WITH_AVRESAMPLE. Are patches excepted?

myrsloik commented 9 years ago

Useful patches are accepted. Mailing lists are for losers. All communication is done on IRC in #darkhold on Rizon.