FFmpeg - avcodec_receive_frame returns AVERROR(EAGAIN)Meaning of ffmpeg output (tbc, tbn, tbr)Rotating videos with FFmpegFFmpeg on AndroidFFmpeg: How to split video efficiently?How to concatenate two MP4 files using FFmpeg?What are the differences and similarities between ffmpeg, libav, and avconv?ffmpeg to extract audio from videoCutting the videos based on start and end time using ffmpegFFmpeg av_read_frame returns a size but no data?FFMPEG (libx264) “height not divisible by 2”

Zhora asks Deckard: "Are you for real?". Was this meant to be significant?

Everyone but three

How to interpret a promising preprint that was never published?

When can a polynomial be written as a polynomial function of another polynomial?

Should I use a resistor between the gate driver and MOSFET (gate pin)?

Is there a difference between PIO and GPIO pins?

How to find location on Cambridge-Mildenhall railway that still has tracks/rails?

What was the difference between a Games Console and a Home Computer?

When is the Circle of Dreams druid's Walker in Dreams feature used?

How can one convert an expression to a string while keeping the quotation marks of strings that are part of the expression?

Why isn't a binary file shown as 0s and 1s?

Is Error correction and detection can be done with out adding extra bits?

Grouping into more groups in one iteration

What are the basics of commands in Minecraft Java Edition?

How to not confuse readers with simultaneous events?

Why won't some unicode characters print to my terminal?

How do you give a date interval with diffuse dates?

ANOVA or Linear Mixed Model?

Strategy to pay off revolving debt while building reserve savings fund?

Why aren't there any women super GMs?

Wordplay addition paradox

What is this green alien supposed to be on the American covers of the "Hitchhiker's Guide to the Galaxy"?

Is straight-up writing someone's opinions telling?

Finding all possible pairs of square numbers in an array



FFmpeg - avcodec_receive_frame returns AVERROR(EAGAIN)


Meaning of ffmpeg output (tbc, tbn, tbr)Rotating videos with FFmpegFFmpeg on AndroidFFmpeg: How to split video efficiently?How to concatenate two MP4 files using FFmpeg?What are the differences and similarities between ffmpeg, libav, and avconv?ffmpeg to extract audio from videoCutting the videos based on start and end time using ffmpegFFmpeg av_read_frame returns a size but no data?FFMPEG (libx264) “height not divisible by 2”






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I'm using an QOpenGL widget to draw frames. However, I'm struggling to get frames by using avcodec_receive_frame. It ended within the block else if (ret == AVERROR(EAGAIN)) and returned -11. I have no idea what made this happen. Also I checked that codecs were fine, so I guess the problem wasn't caused by codecs.



MyDemux.cpp



AVPacket* MyDemux::allocatePacket()

AVPacket* packet = av_packet_alloc();
return packet;


AVFrame* MyDemux::allocateFrame()

AVFrame* frame = av_frame_alloc();
return frame;


int MyDemux::readFrame(AVPacket* packet)

mux.lock();
if (!formatCtx)
std::cout << "formaetCtx is null" << std::endl;
mux.unlock();
return -1;

int ret = av_read_frame(formatCtx, packet);
if (ret == AVERROR_EOF)
return -2;

if (ret != 0)
mux.unlock();
av_packet_free(&packet);
return -1;

media_type = packet->stream_index;
mux.unlock();
return 0;



MyDecode.cpp



void MyDecode::decode(AVFrame* frame, AVPacket* packet)

int ret;
ret = avcodec_send_packet(codecCtx, packet); // this returned 0
while (ret == 0)
ret = avcodec_receive_frame(codecCtx, frame); // this returned -11
if (ret == AVERROR(EINVAL))
std::cout << "codec issue" << std::endl;
av_frame_free(&frame);
return;

else if (ret == AVERROR(EAGAIN)) // program ends here
std::cout << "output is not available this state" << std::endl;
av_frame_free(&frame);
return;

else if (ret == AVERROR(EINVAL))
std::cout << "no more frames" << std::endl;
av_frame_free(&frame);
return;





main.cpp



class MyThread : public QThread

public:

MyDemux demux;
MyDecode video_decode;
myDecode audio_decode;
MyVideoWidget* videoWidget;
AVPacket* packet;
AVFrame* frame;

void initThread()

char* url = "demo.mp4";
demux.openFile(url);
video_decode.openCodec(demux.copy_video_codec_par());
audio_decode.openCodec(demux.copy_audio_codec_par());
packet = demux.allocatePacket();
frame = demux.allocateFrame();

void run()

while (demux.readFrame(packet) != -2)
if (demux.get_media_type() == 0)
video_decode.decode(frame, packet);
videoWidget->paintFrame(frame);

else if (demux.get_media_type() == 1)


video_decode.decode(frame, nullptr);
demux.clear();
demux.close();

;









share|improve this question






























    1















    I'm using an QOpenGL widget to draw frames. However, I'm struggling to get frames by using avcodec_receive_frame. It ended within the block else if (ret == AVERROR(EAGAIN)) and returned -11. I have no idea what made this happen. Also I checked that codecs were fine, so I guess the problem wasn't caused by codecs.



    MyDemux.cpp



    AVPacket* MyDemux::allocatePacket()

    AVPacket* packet = av_packet_alloc();
    return packet;


    AVFrame* MyDemux::allocateFrame()

    AVFrame* frame = av_frame_alloc();
    return frame;


    int MyDemux::readFrame(AVPacket* packet)

    mux.lock();
    if (!formatCtx)
    std::cout << "formaetCtx is null" << std::endl;
    mux.unlock();
    return -1;

    int ret = av_read_frame(formatCtx, packet);
    if (ret == AVERROR_EOF)
    return -2;

    if (ret != 0)
    mux.unlock();
    av_packet_free(&packet);
    return -1;

    media_type = packet->stream_index;
    mux.unlock();
    return 0;



    MyDecode.cpp



    void MyDecode::decode(AVFrame* frame, AVPacket* packet)

    int ret;
    ret = avcodec_send_packet(codecCtx, packet); // this returned 0
    while (ret == 0)
    ret = avcodec_receive_frame(codecCtx, frame); // this returned -11
    if (ret == AVERROR(EINVAL))
    std::cout << "codec issue" << std::endl;
    av_frame_free(&frame);
    return;

    else if (ret == AVERROR(EAGAIN)) // program ends here
    std::cout << "output is not available this state" << std::endl;
    av_frame_free(&frame);
    return;

    else if (ret == AVERROR(EINVAL))
    std::cout << "no more frames" << std::endl;
    av_frame_free(&frame);
    return;





    main.cpp



    class MyThread : public QThread

    public:

    MyDemux demux;
    MyDecode video_decode;
    myDecode audio_decode;
    MyVideoWidget* videoWidget;
    AVPacket* packet;
    AVFrame* frame;

    void initThread()

    char* url = "demo.mp4";
    demux.openFile(url);
    video_decode.openCodec(demux.copy_video_codec_par());
    audio_decode.openCodec(demux.copy_audio_codec_par());
    packet = demux.allocatePacket();
    frame = demux.allocateFrame();

    void run()

    while (demux.readFrame(packet) != -2)
    if (demux.get_media_type() == 0)
    video_decode.decode(frame, packet);
    videoWidget->paintFrame(frame);

    else if (demux.get_media_type() == 1)


    video_decode.decode(frame, nullptr);
    demux.clear();
    demux.close();

    ;









    share|improve this question


























      1












      1








      1


      1






      I'm using an QOpenGL widget to draw frames. However, I'm struggling to get frames by using avcodec_receive_frame. It ended within the block else if (ret == AVERROR(EAGAIN)) and returned -11. I have no idea what made this happen. Also I checked that codecs were fine, so I guess the problem wasn't caused by codecs.



      MyDemux.cpp



      AVPacket* MyDemux::allocatePacket()

      AVPacket* packet = av_packet_alloc();
      return packet;


      AVFrame* MyDemux::allocateFrame()

      AVFrame* frame = av_frame_alloc();
      return frame;


      int MyDemux::readFrame(AVPacket* packet)

      mux.lock();
      if (!formatCtx)
      std::cout << "formaetCtx is null" << std::endl;
      mux.unlock();
      return -1;

      int ret = av_read_frame(formatCtx, packet);
      if (ret == AVERROR_EOF)
      return -2;

      if (ret != 0)
      mux.unlock();
      av_packet_free(&packet);
      return -1;

      media_type = packet->stream_index;
      mux.unlock();
      return 0;



      MyDecode.cpp



      void MyDecode::decode(AVFrame* frame, AVPacket* packet)

      int ret;
      ret = avcodec_send_packet(codecCtx, packet); // this returned 0
      while (ret == 0)
      ret = avcodec_receive_frame(codecCtx, frame); // this returned -11
      if (ret == AVERROR(EINVAL))
      std::cout << "codec issue" << std::endl;
      av_frame_free(&frame);
      return;

      else if (ret == AVERROR(EAGAIN)) // program ends here
      std::cout << "output is not available this state" << std::endl;
      av_frame_free(&frame);
      return;

      else if (ret == AVERROR(EINVAL))
      std::cout << "no more frames" << std::endl;
      av_frame_free(&frame);
      return;





      main.cpp



      class MyThread : public QThread

      public:

      MyDemux demux;
      MyDecode video_decode;
      myDecode audio_decode;
      MyVideoWidget* videoWidget;
      AVPacket* packet;
      AVFrame* frame;

      void initThread()

      char* url = "demo.mp4";
      demux.openFile(url);
      video_decode.openCodec(demux.copy_video_codec_par());
      audio_decode.openCodec(demux.copy_audio_codec_par());
      packet = demux.allocatePacket();
      frame = demux.allocateFrame();

      void run()

      while (demux.readFrame(packet) != -2)
      if (demux.get_media_type() == 0)
      video_decode.decode(frame, packet);
      videoWidget->paintFrame(frame);

      else if (demux.get_media_type() == 1)


      video_decode.decode(frame, nullptr);
      demux.clear();
      demux.close();

      ;









      share|improve this question
















      I'm using an QOpenGL widget to draw frames. However, I'm struggling to get frames by using avcodec_receive_frame. It ended within the block else if (ret == AVERROR(EAGAIN)) and returned -11. I have no idea what made this happen. Also I checked that codecs were fine, so I guess the problem wasn't caused by codecs.



      MyDemux.cpp



      AVPacket* MyDemux::allocatePacket()

      AVPacket* packet = av_packet_alloc();
      return packet;


      AVFrame* MyDemux::allocateFrame()

      AVFrame* frame = av_frame_alloc();
      return frame;


      int MyDemux::readFrame(AVPacket* packet)

      mux.lock();
      if (!formatCtx)
      std::cout << "formaetCtx is null" << std::endl;
      mux.unlock();
      return -1;

      int ret = av_read_frame(formatCtx, packet);
      if (ret == AVERROR_EOF)
      return -2;

      if (ret != 0)
      mux.unlock();
      av_packet_free(&packet);
      return -1;

      media_type = packet->stream_index;
      mux.unlock();
      return 0;



      MyDecode.cpp



      void MyDecode::decode(AVFrame* frame, AVPacket* packet)

      int ret;
      ret = avcodec_send_packet(codecCtx, packet); // this returned 0
      while (ret == 0)
      ret = avcodec_receive_frame(codecCtx, frame); // this returned -11
      if (ret == AVERROR(EINVAL))
      std::cout << "codec issue" << std::endl;
      av_frame_free(&frame);
      return;

      else if (ret == AVERROR(EAGAIN)) // program ends here
      std::cout << "output is not available this state" << std::endl;
      av_frame_free(&frame);
      return;

      else if (ret == AVERROR(EINVAL))
      std::cout << "no more frames" << std::endl;
      av_frame_free(&frame);
      return;





      main.cpp



      class MyThread : public QThread

      public:

      MyDemux demux;
      MyDecode video_decode;
      myDecode audio_decode;
      MyVideoWidget* videoWidget;
      AVPacket* packet;
      AVFrame* frame;

      void initThread()

      char* url = "demo.mp4";
      demux.openFile(url);
      video_decode.openCodec(demux.copy_video_codec_par());
      audio_decode.openCodec(demux.copy_audio_codec_par());
      packet = demux.allocatePacket();
      frame = demux.allocateFrame();

      void run()

      while (demux.readFrame(packet) != -2)
      if (demux.get_media_type() == 0)
      video_decode.decode(frame, packet);
      videoWidget->paintFrame(frame);

      else if (demux.get_media_type() == 1)


      video_decode.decode(frame, nullptr);
      demux.clear();
      demux.close();

      ;






      ffmpeg decoding






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 26 at 10:03







      Jinx

















      asked Mar 26 at 9:51









      JinxJinx

      3119 bronze badges




      3119 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          1














          There is a delay between sending and receiving a frame. When receive returns EAGAIN, you should call send with the next encoded frame, then call receive again.






          share|improve this answer

























          • Sorry I’m not quite sure what u mean. The avcodec_send_packet comes before avcodec_receive_frame. And also they are implemented in a while loop in the main method

            – Jinx
            Mar 26 at 14:45












          • You must keep calling avcodec_send_frame with new data until avcode_receive_frame returns a valid frame.

            – szatmary
            Mar 26 at 14:51










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55354120%2fffmpeg-avcodec-receive-frame-returns-averroreagain%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          There is a delay between sending and receiving a frame. When receive returns EAGAIN, you should call send with the next encoded frame, then call receive again.






          share|improve this answer

























          • Sorry I’m not quite sure what u mean. The avcodec_send_packet comes before avcodec_receive_frame. And also they are implemented in a while loop in the main method

            – Jinx
            Mar 26 at 14:45












          • You must keep calling avcodec_send_frame with new data until avcode_receive_frame returns a valid frame.

            – szatmary
            Mar 26 at 14:51















          1














          There is a delay between sending and receiving a frame. When receive returns EAGAIN, you should call send with the next encoded frame, then call receive again.






          share|improve this answer

























          • Sorry I’m not quite sure what u mean. The avcodec_send_packet comes before avcodec_receive_frame. And also they are implemented in a while loop in the main method

            – Jinx
            Mar 26 at 14:45












          • You must keep calling avcodec_send_frame with new data until avcode_receive_frame returns a valid frame.

            – szatmary
            Mar 26 at 14:51













          1












          1








          1







          There is a delay between sending and receiving a frame. When receive returns EAGAIN, you should call send with the next encoded frame, then call receive again.






          share|improve this answer















          There is a delay between sending and receiving a frame. When receive returns EAGAIN, you should call send with the next encoded frame, then call receive again.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 26 at 16:25

























          answered Mar 26 at 14:41









          szatmaryszatmary

          20.1k6 gold badges30 silver badges47 bronze badges




          20.1k6 gold badges30 silver badges47 bronze badges












          • Sorry I’m not quite sure what u mean. The avcodec_send_packet comes before avcodec_receive_frame. And also they are implemented in a while loop in the main method

            – Jinx
            Mar 26 at 14:45












          • You must keep calling avcodec_send_frame with new data until avcode_receive_frame returns a valid frame.

            – szatmary
            Mar 26 at 14:51

















          • Sorry I’m not quite sure what u mean. The avcodec_send_packet comes before avcodec_receive_frame. And also they are implemented in a while loop in the main method

            – Jinx
            Mar 26 at 14:45












          • You must keep calling avcodec_send_frame with new data until avcode_receive_frame returns a valid frame.

            – szatmary
            Mar 26 at 14:51
















          Sorry I’m not quite sure what u mean. The avcodec_send_packet comes before avcodec_receive_frame. And also they are implemented in a while loop in the main method

          – Jinx
          Mar 26 at 14:45






          Sorry I’m not quite sure what u mean. The avcodec_send_packet comes before avcodec_receive_frame. And also they are implemented in a while loop in the main method

          – Jinx
          Mar 26 at 14:45














          You must keep calling avcodec_send_frame with new data until avcode_receive_frame returns a valid frame.

          – szatmary
          Mar 26 at 14:51





          You must keep calling avcodec_send_frame with new data until avcode_receive_frame returns a valid frame.

          – szatmary
          Mar 26 at 14:51








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55354120%2fffmpeg-avcodec-receive-frame-returns-averroreagain%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현