Category : android-mediacodec

I’m trying to use FFMPEG in C++ using the h264_mediacodec decoder to decode a video on Android. The frame I receive is AV_PIX_FMT_NV12 instead of AV_PIX_FMT_MEDIACODEC, which implies that the hardware decoding isn’t working. I followed this example to set up the decoder. I tried it on Windows with h264_cuvid and it works as expected, ..

Read more

I need to pass to MediaExtractor the data, for this purpose I use this method SetDataSource https://developer.android.com/ndk/reference/group/media#amediaextractor_setdatasourcefd Like this: int32_t NDK_extractor::decode() { FILE *fp = nullptr; media_status_t err; AMediaExtractor *ex = AMediaExtractor_new(); fp = fopen("/storage/emulated/0/Android/data/com.test.debug/files/Models/test.mp3", "rb"); if (fp) { err = AMediaExtractor_setDataSourceFd(ex, fileno(fp), 0, dataSize); } else { LOGE("Failed open file"); return 0; } if ..

Read more

int32_t NDK_extractor::decode(const unsigned char *pData, long dataSize) { LOGD("Using NDK decoder"); FILE *fp = nullptr; media_status_t err; AMediaExtractor *ex = AMediaExtractor_new(); fp = fmemopen((void *) pData, dataSize, "rb"); if (fp) { err = AMediaExtractor_setDataSourceFd(ex, fileno(fp), 0 /*offset*/, dataSize); } else { LOGE("Failed open file"); return 0; } if (err != AMEDIA_OK) { LOGE("SOUND :: Error ..

Read more

I need to make decoding of bytes in android. For this purpose there is AMediaCodec https://developer.android.com/reference/android/media/MediaCodec that use AMediaExtractor https://developer.android.com/reference/android/media/MediaExtractor as a reader. But problem is that I can’t use direct approach by set path to file that should be decoded because of special structure of custom file format. It means – data that I ..

Read more

media_status_t status = AMediaCodec_configure(mCodec->codec, androidMediaFormat, mOutputTexture.nativeWindow, NULL, 0); if (status != AMEDIA_OK) { LOG_E("Could not configure video decoder, status = %d", status); AMediaFormat_delete(androidMediaFormat); mState = DecoderHWState::ERROR_STATE; return Error::OPERATION_FAILED; } status = AMediaCodec_start(mCodec->codec); if (status != AMEDIA_OK){ LOG_E("MediaCodec start failed, status = %d", status); mState = DecoderHWState::ERROR_STATE; return Error::OPERATION_FAILED; } the log just shows error MediaCodec ..

Read more