From e60b018c7416a9a0608768703166973f37e5e326 Mon Sep 17 00:00:00 2001 From: Rodger Combs Date: Tue, 9 Jun 2015 02:32:18 -0500 Subject: [PATCH] lavf/segment: add an option to allow breaking on non-keyframes Signed-off-by: Michael Niedermayer --- libavformat/segment.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/segment.c b/libavformat/segment.c index 1162ea2122..4418d0f338 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -111,6 +111,7 @@ typedef struct SegmentContext { int64_t initial_offset; ///< initial timestamps offset, expressed in microseconds char *reference_stream_specifier; ///< reference stream specifier int reference_stream_index; + int break_non_keyframes; SegmentListEntry cur_entry; SegmentListEntry *segment_list_entries; @@ -780,7 +781,7 @@ static int seg_write_packet(AVFormatContext *s, AVPacket *pkt) pkt->stream_index == seg->reference_stream_index ? seg->frame_count : -1); if (pkt->stream_index == seg->reference_stream_index && - pkt->flags & AV_PKT_FLAG_KEY && + (pkt->flags & AV_PKT_FLAG_KEY || seg->break_non_keyframes) && seg->segment_frame_count > 0 && (seg->cut_pending || seg->frame_count >= start_frame || (pkt->pts != AV_NOPTS_VALUE && @@ -920,6 +921,7 @@ static const AVOption options[] = { { "segment_start_number", "set the sequence number of the first segment", OFFSET(segment_idx), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E }, { "segment_wrap_number", "set the number of wrap before the first segment", OFFSET(segment_idx_wrap_nb), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E }, { "strftime", "set filename expansion with strftime at segment creation", OFFSET(use_strftime), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, E }, + { "break_non_keyframes", "allow breaking segments on non-keyframes", OFFSET(break_non_keyframes), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, E }, { "individual_header_trailer", "write header/trailer to each segment", OFFSET(individual_header_trailer), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E }, { "write_header_trailer", "write a header to the first segment and a trailer to the last one", OFFSET(write_header_trailer), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E },