Hi, On Tue, Mar 29, 2011 at 3:20 AM, Anton Khirnov <[email protected]> wrote: > On Mon, Mar 28, 2011 at 09:56:07PM -0700, Ronald S. Bultje wrote: >> Hi, >> >> On Mon, Mar 28, 2011 at 3:36 AM, Anton Khirnov <[email protected]> wrote: >> > --- >> > libavformat/matroskaenc.c | 2 +- >> > libavformat/utils.c | 7 +++++++ >> > 2 files changed, 8 insertions(+), 1 deletions(-) >> > >> > diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c >> > index 4f9bf0a..54c74a6 100644 >> > --- a/libavformat/matroskaenc.c >> > +++ b/libavformat/matroskaenc.c >> > @@ -908,7 +908,7 @@ static int mkv_write_ass_blocks(AVFormatContext *s, >> > AVIOContext *pb, AVPacket *p >> > size -= start - data; >> > sscanf(data, "Dialogue: %d,", &layer); >> > i = snprintf(buffer, sizeof(buffer), "%"PRId64",%d,", >> > - s->streams[pkt->stream_index]->nb_frames++, layer); >> > + s->streams[pkt->stream_index]->nb_frames, layer); >> > size = FFMIN(i+size, sizeof(buffer)); >> > memcpy(buffer+i, start, size-i); >> > >> > diff --git a/libavformat/utils.c b/libavformat/utils.c >> > index 7ece078..9b0c558 100644 >> > --- a/libavformat/utils.c >> > +++ b/libavformat/utils.c >> > @@ -3005,6 +3005,9 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt) >> > return ret; >> > >> > ret= s->oformat->write_packet(s, pkt); >> > + >> > + if (ret >= 0) >> > + s->streams[pkt->stream_index]->nb_frames++; >> > return ret; >> > } >> > >> > @@ -3122,6 +3125,8 @@ int av_interleaved_write_frame(AVFormatContext *s, >> > AVPacket *pkt){ >> > return ret; >> > >> > ret= s->oformat->write_packet(s, &opkt); >> > + if (ret >= 0) >> > + s->streams[opkt.stream_index]->nb_frames++; >> > >> > av_free_packet(&opkt); >> > pkt= NULL; >> > @@ -3144,6 +3149,8 @@ int av_write_trailer(AVFormatContext *s) >> > break; >> > >> > ret= s->oformat->write_packet(s, &pkt); >> > + if (ret >= 0) >> > + s->streams[pkt.stream_index]->nb_frames++; >> > >> > av_free_packet(&pkt); >> >> Are you sure this last piece is correct? It seems to me it may end up >> that nb_frames is 1 more than the actual number of frames written for >> formats where a frame != a packet. >> > > No I'm not :) > Is there any way for lavf to know whether packet ~ frame?
Not really. Can you confirm (likely requires a little debugging) that either with or without that piece of code, the number of mp2/3 frames written into a Xing or MPEG file is correct? Ronald _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
