[FFmpeg-devel] [PATCH 1/3] utils.c: when packets are written by s->oformat->write_packet( ), add output packet size to out_bytes.
Michael Smithng
michael at transparentpixel.com
Tue Aug 14 04:16:54 CEST 2012
When interleave_packet() is done (returns 0), return out_bytes instead of normal return (0).
---
libavformat/utils.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 7b45944..6ca377f 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3683,6 +3683,7 @@ static int interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *in, in
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt){
int ret, flush = 0;
+ int out_bytes = 0; // CK: output bytes
if (pkt) {
AVStream *st= s->streams[ pkt->stream_index];
@@ -3706,12 +3707,17 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt){
for(;;){
AVPacket opkt;
int ret= interleave_packet(s, &opkt, pkt, flush);
- if(ret<=0) //FIXME cleanup needed for ret<0 ?
- return ret;
+ if(ret<=0) { //FIXME cleanup needed for ret<0 ?
+ // CK: return number of output bytes
+ if (ret >= 0) ret = out_bytes;
+ return ret;
+ }
ret= s->oformat->write_packet(s, &opkt);
- if (ret >= 0)
+ if (ret >= 0) {
s->streams[opkt.stream_index]->nb_frames++;
+ out_bytes += opkt.size; // CK: accumulate out_bytes
+ }
av_free_packet(&opkt);
pkt= NULL;
--
1.7.11.3
More information about the ffmpeg-devel
mailing list