Changes between Initial Version and Version 1 of Ticket #10500


Ignore:
Timestamp:
Aug 1, 2023, 7:40:38 PM (3 years ago)
Author:
Igor Serganov
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #10500 – Description

    initial v1  
    55I am doing `av_packet_free` and `av_frame_free` of allocated packet/frames during main transcoding loop (see attached file).
    66
     7
     8The actual transcoding loop that runs 24/7:
     9
     10
     11{{{
     12while (av_read_frame(ctx, input_packet) == 0)
     13    {
     14        int response = avcodec_send_packet(decctx, input_packet);
     15        while (response >= 0)
     16        {
     17            response = avcodec_receive_frame(decctx, input_frame);
     18            if (response == AVERROR(EAGAIN) || response == AVERROR_EOF)
     19            {
     20                av_frame_unref(input_frame);
     21                av_packet_unref(input_packet);
     22                goto read_input;
     23            }
     24            else if (response < 0)
     25            {
     26                return response;
     27            }
     28            if (response >= 0)
     29            {
     30                input_frame->pts = in_pts;
     31                in_pts += input_frame->nb_samples;
     32                response = av_buffersrc_add_frame(src, input_frame);
     33                if (response < 0)
     34                {
     35                    fprintf(stderr, "Cannot send frame to afilter:");
     36                    av_frame_unref(input_frame);
     37                    av_packet_unref(input_packet);
     38                    goto read_input;
     39                }
     40                while ((response = av_buffersink_get_frame(sink, out_frame)) >= 0)
     41                {
     42                    out_frame->pts = out_pts;
     43                    out_pts += out_frame->nb_samples;
     44                    encode(ofmt_ctx, istream, ostream, encctx, audio_stream_index, out_frame);
     45                    av_frame_unref(out_frame);
     46                }
     47                av_frame_unref(input_frame);
     48            }
     49        }
     50        av_packet_unref(input_packet);
     51    }
     52}}}
     53
     54
    755I cannot call it a 'memory leak' as all the resources are being freed in case if application processes finite input, exits transcoding loop and deallocates all the resources. Though if I do everything correctly in my code, I still consider this as a serious issue since with every read of decoded packet I can see increase of memory usage which is not reduced in the following iteration.
    856