[FFmpeg-user] avcodec_open2() fails with error "Operation not permitted"
Juha Heinanen
jh at tutpro.com
Wed May 20 15:43:42 EEST 2020
I'm trying to use h264_mediacodec decoder in my Android app. The decoder
is included in my ffmpeg build from master:
Enabled decoders:
h264 rawvideo vp8_mediacodec vp9_mediacodec h264_mediacodec vp8 vp9
I have followed the examples, e.g.,
https://ffmpeg.org/doxygen/trunk/decode__video_8c_source.html
and accordingly written this piece of code:
if (av_jni_set_java_vm(g_ctx.javaVM, NULL) != 0)
LOGW("av_jni_set_java_vm failed!");
AVCodec *av_codec;
AVCodecContext *av_ctx;
av_codec = avcodec_find_decoder_by_name("h264_mediacodec");
if (av_codec != NULL)
LOGW("found h264_mediacodec\n");
av_ctx = avcodec_alloc_context3(av_codec);
if (av_ctx != NULL)
LOGW("allocated context\n");
int ret = avcodec_open2(av_ctx, av_codec, NULL);
if (ret < 0) {
char str[AV_ERROR_MAX_STRING_SIZE];
memset(str, 0, sizeof(str));
av_strerror(ret, str, sizeof(str));
LOGW("avcodec_open2 error: %d \"%s\"\n", ret, str);
} else {
LOGW("avcodec_open2 success\n");
}
When it is executed, I get to log:
05-20 15:27:56.638 13664 13664 D Baresip Lib: found h264_mediacodec
05-20 15:27:56.638 13664 13664 D Baresip Lib: allocated context
05-20 15:27:56.638 13664 13664 D Baresip Lib: avcodec_open2 error: -1 "Operation not permitted"
Any ideas why avcodec_open2() fails?
-- Juha
More information about the ffmpeg-user
mailing list