Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. ffmpeg using MediaCodec, avcodec_open2 says error code:-1 (0xffffffff) text: “Operation not permitted”
Forum Update on Monday, May 27th 2025

ffmpeg using MediaCodec, avcodec_open2 says error code:-1 (0xffffffff) text: “Operation not permitted”

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 3 Posters 3.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • delamorD Offline
    delamorD Offline
    delamor
    wrote on last edited by
    #1

    Qt version: 5.7.1
    ffmpeg version: n3.3
    Android version: 5.1.1 ( but I've tried on some different devices )

    I'm trying to use the Android API MediaCoded that have been supported by ffmpeg but while I try to open the codec I got "Operation not permitted" all times, I've tried some changes and I've tried to find examples without not luck.

    This is what I'm doing

    av_jni_set_java_vm(QAndroidJniEnvironment::javaVM(), NULL);
    
    av_register_all();
    avcodec_register_all();
    
    AVCodec *_codec(nullptr);
    AVCodecContext *_codecContext(nullptr);
    
    if (_codec == nullptr)
        _codec = avcodec_find_decoder_by_name("h264_mediacodec");
    
    if (_codecContext == nullptr)
        _codecContext = avcodec_alloc_context3(_codec);
    
    int ret = 0;
    if( (ret = avcodec_open2(_codecContext, _codec, NULL)) < 0 ) {
    
        char str[AV_ERROR_MAX_STRING_SIZE];
        memset(str, 0, sizeof(str));
        av_strerror(ret, str, sizeof(str));
    
        qDebug("avcodec_open2 \"%s\" error[code:%d text:\"%s\"]",_codec->long_name, ret, str);
    }
    

    And I'm getting this output

    avcodec_open2 "H.264 Android MediaCodec decoder" error[code:-1 text:"Operation not permitted"]
    

    What I'm doing wrong?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      I haven't used ffmpeg on that platform but since you are looking after h264 and it not beeing a free format, I'd first start by printing everything that ffmpeg provides to check if the support is there.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • delamorD Offline
        delamorD Offline
        delamor
        wrote on last edited by
        #3

        I've already checked that, was also my first point

            av_jni_set_java_vm(QAndroidJniEnvironment::javaVM(), NULL);
        
            av_register_all();
            avcodec_register_all();
        
            AVCodec *current_codec = av_codec_next(current_codec);
            while (current_codec != NULL)
            {
                QString name(current_codec->name);
                if(name.contains("mediacodec"))
                    qDebug("codec:%s",current_codec->name);
                current_codec = av_codec_next(current_codec);
            }
        

        With output

        codec:h264_mediacodec
        codec:hevc_mediacodec
        codec:mpeg4_mediacodec
        codec:vp8_mediacodec
        codec:vp9_mediacodec
        

        So the codecs are there.

        P.S.:
        Thanks for your suggestion :)

        1 Reply Last reply
        0
        • R Offline
          R Offline
          rohit_n
          wrote on last edited by
          #4

          Hey,
          Just wondering if you found any solution to this?

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved