On Fri, Apr 11, 2008 at 07:24:31AM +0000, Vladimir Eremeev wrote:
> I am struggling with this problem for already a week.
> My program captures the MPEG 2 Transpotr Stream from a DVB-S card and saves
> its
> parts to files in the MPEG Program Stream.
>
> I use libav* functions to demux and mux again data. Video and audio are
> recorded just fine.
>
> The problem is that after about 1 hour of work the program consumes all
> available RAM and the system kills it. This is undesirable, as my program is
> going to work forever in a daemon mode.
>
> The main cycle is general:
>
> AVPacket pkt;
>
> while(!is_exiting()) {
> av_read_frame(input,&pkt);
> [ do something with the packet,
> possibly write it with av_write_frame() ]
> av_free_packet(&pkt);
> }
>
> If I take out calls to av_read_frame and av_free_packet and replace them with
> a
> simple reading to the static array (the code is following), the program works
> fine and doesn't go over 10Mb of RAM.
>
> This cycle doesn't drive the program beyond 10Mb of memory consumption.
>
> int thread_proc(void)
> {uint8_t buf[10240];
> int mqsize=0;
>
> linsys_read(this,buf,1024); //is a function reading the data from a device.
> while(!is_exiting()){
> linsys_read(this,buf,10240);
> if(is_exiting())
> break;
> }
> return 0;
> }
>
> And another cycle, this eats all available memory.
> I have read about issue #361 (https://roundup.mplayerhq.hu/roundup/ffmpeg/
> issue361) and have set up before it:
>
> input->pb->is_streamed=1;
> input->pb->max_packet_size=188;
> input->flags|=AVFMT_NOFILE|AVFMT_FLAG_IGNIDX;
> input->max_index_size=1024*50;
> input->max_picture_buffer=1024*100;
>
> int thread_proc(void)
> {AVPacket pkt;
> AVFormatParameters ap;
>
> memset(&ap, 0, sizeof(ap));
> ap.prealloced_context=1;
>
> int r=av_open_input_stream(&input,input->pb,"linsys",input->iformat,&ap);
> r=av_find_stream_info(input);
>
> while(!is_exiting()){
> av_read_frame(input,&pkt);
> if( pkt.stream_index < input->nb_streams ){
> int pid=input->streams[pkt.stream_index]->id;
>
> if ( [if the packet is to be saved] ){ //program eats the memory even
> if
> this condition is never true
> int r=av_write_frame(m_tasks[i]->output,&pkt); //and this call is
> never
> executed.
> }
> }
> av_free_packet(&pkt);
> }
> }
>
> If I comment out the internal if( ) and leave simply av_read_frame() and
> av_free_packet(), the memory consumption still grows.this is odd, i thought the interleaving code from write_frame was causing it, anyway, its somewhat difficult to follow your explanations, you should concentrate on finding a minimum case that fails not show us 5 cases with comments saying what all doesnt solve it. > > My program works on windows and uses the specific API for the DVB-S device, > provided by the manufacturer. Since that I cannot use ffmpeg command line > utility and see how it behaves. i assume they havnt removed write() and fwrite() from windows so you can store the data to disk and try ffmpeg on it. Anyway you also should learn how to use a debugger to obtain a backtrace from realloc(), i think you said it was realloc() which allocated huge amounts of memory. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Breaking DRM is a little like attempting to break through a door even though the window is wide open and the only thing in the house is a bunch of things you dont want and which you would get tomorrow for free anyway
signature.asc
Description: Digital signature
_______________________________________________ libav-user mailing list [email protected] https://lists.mplayerhq.hu/mailman/listinfo/libav-user
