I just have a question about how to use ffmpeg/libavcodec/libstagfright.cpp
: I try to avcodec_open2(st->codec, codec)
when I have use ffmpeg to set codec->id
as CODEC_ID_H264,codec->name
as libstagefright_h264
,that means I will open
AVCodec ff_libstagefright_h264_decoder
.
but when Stagefright_init->OMXCodec::Create->configureCodec-> initOutputFormat(meta)
, the process just Quit ! It is a bazinga !
I knew that meta is Metadata, its data comes from codec->extradata
, and in here, it means sps and pps, am I right?
How can I use libstagefright
sucessfully in ffmpeg? Can somebody give me an example?
It works at ICS4.0.3 ,Moto XT910,FFmpeg 0.7
I use extradata for store MediaFileName,then get metadata from codes:
DataSource::RegisterDefaultSniffers();
sp source ;
source = createSource((char*)MeidaFileName);
if(source==NULL){
return -1 ;
}
meta = source->getFormat();
if(!meta->findData(kKeyAVCC, &type, &data, &data_size))
{
return -1 ;
}
meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_AVC);
then you can OMX::create(there are some difference for Android 2.3 and ICS)
Im actually working on providing stagefright to my ffmpeg library on Android. I made some changes to original libstagefright.cpp from ffmpeg/libav but it is still not stable. After stabilizing it I will create pull request for ffmpeg/libav team. You can look around on my project: in "hwaccel" branch.
It is available at AndroidFFmpeg/FFmpegLibrary/jni/ffstagefright.cpp directory.
To use this library you have call standard ffmpeg methods and open insteed of standard h264 codec libstagefright_h264 codec:
AVCodec *codec = avcodec_find_decoder_by_name("libstagefright_h264");