libav MMAL Runtime Errors

Discussion in 'Computer Programming, Emulation, and Game Modding' started by gudenau, Jan 28, 2017.

  1. gudenau
    OP

    gudenau Largely ignored

    Member
    8
    GBAtemp Patron
    gudenau is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    Jul 7, 2010
    United States
    /dev/random
    I compiled ffmpeg on my Raspbery Pi Zero. (Yes it took forever, but I could not get cross compiling working, different problem) When I run ffmpeg it outputs this:

    Code:
    ffmpeg version N-83120-ge7dec52 Copyright (c) 2000-2017 the FFmpeg developers
      built with gcc 4.9.2 (Raspbian 4.9.2-10)
      configuration: --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-mmal --extra-cflags=-ftree-vectorize
      libavutil      55. 43.100 / 55. 43.100
      libavcodec     57. 72.100 / 57. 72.100
      libavformat    57. 62.100 / 57. 62.100
      libavdevice    57.  2.100 / 57.  2.100
      libavfilter     6. 69.100 /  6. 69.100
      libswscale      4.  3.101 /  4.  3.101
      libswresample   2.  4.100 /  2.  4.100
      libpostproc    54.  2.100 / 54.  2.100
    Hyper fast Audio and Video encoder
    usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
    
    Use -h to get full help or, even better, run 'man ffmpeg'
    
    Then filtering the FFMPeg codecs with grep for h264 shows this:
    Code:
    ffmpeg version N-83120-ge7dec52 Copyright (c) 2000-2017 the FFmpeg developers
      built with gcc 4.9.2 (Raspbian 4.9.2-10)
      configuration: --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-mmal --extra-cflags=-ftree-vectorize
      libavutil      55. 43.100 / 55. 43.100
      libavcodec     57. 72.100 / 57. 72.100
      libavformat    57. 62.100 / 57. 62.100
      libavdevice    57.  2.100 / 57.  2.100
      libavfilter     6. 69.100 /  6. 69.100
      libswscale      4.  3.101 /  4.  3.101
      libswresample   2.  4.100 /  2.  4.100
      libpostproc    54.  2.100 / 54.  2.100
     D.V.LS h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_mmal )
    
    Here is my code that uses libav, at the moment just attempting to decode the video and ignore the output.
    Code:
    #ifndef INBUF_SIZE
    #define INBUF_SIZE 4096
    #endif FF_INPUT_BUFFER_PADDING_SIZE
    #ifndef FF_INPUT_BUFFER_PADDING_SIZE
    #define FF_INPUT_BUFFER_PADDING_SIZE 32
    #endif
    
    int decode_frame(AVCodecContext *instance, AVFrame *frame, int *frameCount, AVPacket *packet){
        int length;
        int gotFrame;
       
        length = avcodec_decode_video2(instance, frame, &gotFrame, packet);
        assert(length >= 0);
       
        if(gotFrame){
            (*frameCount)++;
        }
        if(packet->data){
            packet->size -= length;
            packet->data += length;
        }
       
        return 0;
    }
    
    void initFFMPEG(void){
        // Register all the things
        av_register_all();
       
        AVPacket packet;
        av_init_packet(&packet);
       
        AVCodec *codec;
        codec = avcodec_find_decoder_by_name("h264_mmal");
        assert(codec);
       
        AVCodecContext *instance;
        instance = avcodec_alloc_context3(codec);
        assert(instance);
       
        assert(avcodec_open2(instance, codec, NULL) >= 0);
       
        FILE *file = fopen("/opt/vc/src/hello_pi/hello_video/test.h264", "rb");
        assert(file);
       
        AVFrame *frame;
        frame = av_frame_alloc();
        assert(frame);
       
        uint8_t inbuf[INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
        memset(inbuf + INBUF_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);
       
        int frameCount = 0;
        for(;;){
            packet.size = fread(inbuf, 1, INBUF_SIZE, file);
            if(!packet.size){
                break;
            }
           
            packet.data = inbuf;
            while(packet.size > 0){
                assert(decode_frame(instance, frame, &frameCount, &packet) >= 0);
            }
        }
       
        packet.data = NULL;
        packet.size = 0;
        decode_frame(instance, frame, &frameCount, &packet);
       
        fclose(file);
       
        avcodec_close(instance);
        av_free(instance);
        av_frame_free(&frame);
    }
    The program outputs this:
    Code:
    mmal: mmal_port_event_get: vc.ril.video_decode(1:0) port 0x2c91610, no event buffer left for ERRO
    mmalipc: mmal_vc_handle_event_msg: no event buffer available to receive event (2)
    mmal: mmal_port_event_get: vc.ril.video_decode(1:0) port 0x2c91610, no event buffer left for ERRO
    mmalipc: mmal_vc_handle_event_msg: no event buffer available to receive event (2)
    mmal: mmal_port_event_get: vc.ril.video_decode(1:0) port 0x2c91610, no event buffer left for ERRO
    mmalipc: mmal_vc_handle_event_msg: no event buffer available to receive event (2)
    mmal: mmal_port_event_get: vc.ril.video_decode(1:0) port 0x2c91610, no event buffer left for ERRO
    mmalipc: mmal_vc_handle_event_msg: no event buffer available to receive event (2)
    mmal: mmal_port_event_get: vc.ril.video_decode(1:0) port 0x2c91610, no event buffer left for ERRO
    mmalipc: mmal_vc_handle_event_msg: no event buffer available to receive event (2)
    mmal: mmal_port_event_get: vc.ril.video_decode(1:0) port 0x2c91610, no event buffer left for ERRO
    mmalipc: mmal_vc_handle_event_msg: no event buffer available to receive event (2)
    mmal: mmal_port_event_get: vc.ril.video_decode(1:0) port 0x2c91610, no event buffer left for ERRO
    mmalipc: mmal_vc_handle_event_msg: no event buffer available to receive event (2)
    mmal: mmal_port_event_get: vc.ril.video_decode(1:0) port 0x2c91610, no event buffer left for ERRO
    mmalipc: mmal_vc_handle_event_msg: no event buffer available to receive event (2)
    mmal: mmal_port_event_get: vc.ril.video_decode(1:0) port 0x2c91610, no event buffer left for ERRO
    mmalipc: mmal_vc_handle_event_msg: no event buffer available to receive event (2)
    mmal: mmal_port_event_get: vc.ril.video_decode(1:0) port 0x2c91610, no event buffer left for ERRO
    mmalipc: mmal_vc_handle_event_msg: no event buffer available to receive event (2)
    mmal: mmal_port_event_get: vc.ril.video_decode(1:0) port 0x2c91610, no event buffer left for ERRO
    mmalipc: mmal_vc_handle_event_msg: no event buffer available to receive event (2)
    mmal: mmal_port_event_get: vc.ril.video_decode(1:0) port 0x2c91610, no event buffer left for ERRO
    mmalipc: mmal_vc_handle_event_msg: no event buffer available to receive event (2)
    mmal: mmal_port_event_get: vc.ril.video_decode(1:0) port 0x2c91610, no event buffer left for ERRO
    mmalipc: mmal_vc_handle_event_msg: no event buffer available to receive event (2)
    mmal: [h264_mmal @ 0x2c903e0] MMAL error 2 on control port
    [h264_mmal @ 0x2c903e0] MMAL error 2 on control port
    [h264_mmal @ 0x2c903e0] MMAL error 2 on control port
    [h264_mmal @ 0x2c903e0] MMAL error 2 on control port
    mmal_port_event_get: vc.ril.video_decode(1:0) port 0x2c91610, no event buffer left for ERRO
    mmalipc: mmal_vc_handle_event_msg: no event buffer available to receive event (2)
    [h264_mmal @ 0x2c903e0] MMAL error 2 on control port
    [h264_mmal @ 0x2c903e0] MMAL error 2 on control port
    [h264_mmal @ 0x2c903e0] MMAL error 2 on control port
    [h264_mmal @ 0x2c903e0] MMAL error 2 on control port
    [h264_mmal @ 0x2c903e0] MMAL error 2 on control port
    [h264_mmal @ 0x2c903e0] MMAL error 2 on control port
    [h264_mmal @ 0x2c903e0] MMAL error 2 on control port
    [h264_mmal @ 0x2c903e0] MMAL error 2 on control port
    [h264_mmal @ 0x2c903e0] MMAL error 2 on control port
    [h264_mmal @ 0x2c903e0] MMAL error 2 on control port
    [h264_mmal @ 0x2c903e0] MMAL error 2 on control port
    [h264_mmal @ 0x2c903e0] MMAL error 2 on control port
    [h264_mmal @ 0x2c903e0] MMAL error 2 on control port
    [h264_mmal @ 0x2c903e0] MMAL error 2 on control port
    [h264_mmal @ 0x2c903e0] MMAL error 2 on control port
    [h264_mmal @ 0x2c903e0] Did not get output frame from MMAL.
    test: src/main.c:243: decode_frame: Assertion `length >= 0' failed.
    Aborted
    
    And this is my makefile:
    Code:
    SOURCE            = src
    BUILD            = build
    BIN                = test
    
    GCC                = gcc
    LINKER            = gcc
    
    INCLUDE_PATHS    = /opt/vc/include
    LIBRARY_PATHS    = /opt/vc/lib /usr/lib/gcc/arm-linux-gnueabihf/4.9
    
    SOURCES            = $(wildcard $(SOURCE)/*.c)
    OBJECTS            = $(patsubst $(SOURCE)/%.c,$(BUILD)/%.o,$(SOURCES))
    
    MMAL_LIBS        = mmal mmal_core mmal_components mmal_util mmal_vc_client
    FFMPEG_LIBS        = avformat avcodec swresample avutil
    LIBRARIES        = $(FFMPEG_LIBS) $(MMAL_LIBS) bcm_host pthread m z
    
    CFLAGS            = -c $(addprefix -I,$(INCLUDE_PATHS)) -Wall
    LFLAGS            = $(addprefix -l,$(LIBRARIES)) $(addprefix -L,$(LIBRARY_PATHS))
    
    all: $(BIN)
    
    clean:
        rm $(BIN) $(OBJECTS)
    
    $(BIN): $(OBJECTS)
        $(LINKER) $^ $(LFLAGS) -o $@
    
    $(BUILD)/%.o: $(SOURCE)/%.c dirs
        $(GCC) $(CFLAGS) $< -o $@
    
    dirs:
        mkdir -p $(BUILD)
    

    How can I fix this?
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice