Opened 13 years ago

Closed 13 years ago

#521 closed defect (invalid)

avio_open_dyn_buf()/avio_close_dyn_buf(), limit the memory usage

Reported by: Denis Owned by:
Priority: normal Component: undetermined
Version: 0.8.3 Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

In my program the functions "avio_open_dyn_buf() / avio_close_dyn_buf()" work fine. On "avio_close_dyn_buf()" I can save the buffer in a file and the file can be played correctly.
In order to limit the memory usage, I have inserted in my code this:

DynBuffer *d= (DynBuffer*)pFormatCtx->pb->opaque;
QByteArray QBAByteIn((const char*)d->buffer, d->pos);
QFMPGFileOut.write(QBAByteIn);
d->pos= d->size= 0;

that's executed many times before "avio_close_dyn_buf()" function.
This works only with codecs CODEC_ID_THEORA and
CODEC_ID_MPEG4 but not with codecs CODEC_ID_VP8 and CODEC_ID_H264.
Is this a bug or is not possible to extract something from the buffer before "avio_close_dyn_buf()"?

See the source code attached.

Attachments (1)

qthcamera.cpp (17.9 KB ) - added by Denis 13 years ago.

Download all attachments as: .zip

Change History (3)

by Denis, 13 years ago

Attachment: qthcamera.cpp added

comment:1 by Denis, 13 years ago

dump!

comment:2 by reimar, 13 years ago

Resolution: invalid
Status: newclosed

You selected the mp4/mov muxer. That one needs to seek backwards and update data later on after everything is written.
That obviously is not possible if you dropped all of the data in the dynbuf.
At the very least you have to set pFormatCtx->pb->seekable to 0, because your change means that it is not possible for the muxer to go back and modify data it has written out previously.
But that will then result in the mov muxer bailing out because it can't work with that.
You can get something similar by selecting the ism format instead. But while it is basically the same as mov/mp4 according to code comments QuickTime can't handle it.

Note: See TracTickets for help on using tickets.