I am writing an application, capturing the MPEG2 Transport Stream from
a DVB-S device and saving its parts to files according to the user
defined schedule.
I have found that sometimes
Basically, the main cycle is the following
av_open_input_stream( ... )
av_find_stream_info( ... )
while(!is_exiting()){
AVPacket pkt;
av_read_frame(&pkt)
if( [pkt has to be saved] )
av_write_frame( )
av_free_packet(&pkt);
}
However, sometimes my program begins eating more and more memory, and
finally the system kills it. It happens quite often, keeping in mind
that it is a server, which must run forever.
I have found that during that growth of the memory consumption,
input->packet_buffer
quickly growing in size and its head doesn't change.
That is, the packet has stuck in the buffer head and therefore the
buffer tail is growing
I have added a code, displaying a program internal state and a function
calculating the length of the packet buffer:
int get_av_packetlist_size(AVPacketList *pl)
{int sz;
AVPacketList *p;
for(p=pl,sz=0; p!=NULL; p=p->next, sz++)
;
return sz;
}
Here are the exerpts:
local time: Thu May 22 19:28:50 2008
input: packet buffer size 32 (input -> packet_buffer)
input: PTS of packet buffer head 7191527679 (input -> packet_buffer -> pkt.pts)
input: DTS of packet buffer head 7191527679 (input -> packet_buffer -> pkt.dts)
...
local time: Thu May 22 20:32:15 2008
packet buffer size 9209
PTS of packet buffer head -9223372036854775808 (looks like the result of printf
("%lld",AV_NOPTS_VALUE))
DTS of packet buffer head 8589938522
...
local time: Thu May 22 20:32:57 2008
packet buffer size 21360
PTS of packet buffer head -9223372036854775808
DTS of packet buffer head 8589938522
...
local time: Thu May 22 20:35:03 2008
packet buffer size 39063
PTS of packet buffer head -9223372036854775808
DTS of packet buffer head 8589938522
...
local time: Thu May 22 21:36:05 2008
packet buffer size 177150
PTS of packet buffer head -9223372036854775808
DTS of packet buffer head 8589938522
...
...
local time: Fri May 23 02:00:42 2008
packet buffer size 400762
PTS of packet buffer head -9223372036854775808
DTS of packet buffer head 8589938522
Then the system has killed the process, because according to
the /proc/PID/ status it has occupied more than 500Mb of RAM.
Any ideas of how to cure that?
Anyone have seen similar?
Currently, there is a krude hack in my mind.
Monitor the packet buffer size and its head and it the same packet is
seen several times, simply remove it from the head of the input buffer.
I also have found that this is happening during the empty periods, when
there is no saving tasks ('if' is not executed in the above code).
Studying further details.
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user