Skip to content

Commit 95b7fa1

Browse files
committed
oggenc: Support flushing the muxer
This allows the caller to write all buffered data to disk, allowing the caller to know at what byte position in the file a certain packet starts (any packet written after the flush will be located after that byte position). Signed-off-by: Martin Storsjö <[email protected]>
1 parent d5a5598 commit 95b7fa1

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

libavformat/oggenc.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ static int ogg_write_header(AVFormatContext *s)
545545
return 0;
546546
}
547547

548-
static int ogg_write_packet(AVFormatContext *s, AVPacket *pkt)
548+
static int ogg_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
549549
{
550550
AVStream *st = s->streams[pkt->stream_index];
551551
OGGStreamContext *oggstream = st->priv_data;
@@ -583,6 +583,23 @@ static int ogg_write_packet(AVFormatContext *s, AVPacket *pkt)
583583
return 0;
584584
}
585585

586+
static int ogg_write_packet(AVFormatContext *s, AVPacket *pkt)
587+
{
588+
int i;
589+
590+
if (pkt)
591+
return ogg_write_packet_internal(s, pkt);
592+
593+
for (i = 0; i < s->nb_streams; i++) {
594+
OGGStreamContext *oggstream = s->streams[i]->priv_data;
595+
if (oggstream->page.segments_count)
596+
ogg_buffer_page(s, oggstream);
597+
}
598+
599+
ogg_write_pages(s, 2);
600+
return 0;
601+
}
602+
586603
static int ogg_write_trailer(AVFormatContext *s)
587604
{
588605
int i;
@@ -623,6 +640,6 @@ AVOutputFormat ff_ogg_muxer = {
623640
.write_header = ogg_write_header,
624641
.write_packet = ogg_write_packet,
625642
.write_trailer = ogg_write_trailer,
626-
.flags = AVFMT_TS_NEGATIVE,
643+
.flags = AVFMT_TS_NEGATIVE | AVFMT_ALLOW_FLUSH,
627644
.priv_class = &ogg_muxer_class,
628645
};

libavformat/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
#define LIBAVFORMAT_VERSION_MAJOR 55
3333
#define LIBAVFORMAT_VERSION_MINOR 19
34-
#define LIBAVFORMAT_VERSION_MICRO 0
34+
#define LIBAVFORMAT_VERSION_MICRO 1
3535

3636
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
3737
LIBAVFORMAT_VERSION_MINOR, \

0 commit comments

Comments
 (0)