From: Andriy Gelman <andriy.gel...@gmail.com> Signed-off-by: Andriy Gelman <andriy.gel...@gmail.com> --- doc/muxers.texi | 6 ++++++ libavformat/nut.h | 3 ++- libavformat/nutenc.c | 10 ++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/doc/muxers.texi b/doc/muxers.texi index 813b4678f4..ace236fca6 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -1822,6 +1822,12 @@ Change the syncpoint usage in nut: The @var{none} and @var{timestamped} flags are experimental. @item -write_index @var{bool} Write index at the end, the default is to write an index. +@item -header_period @var{value} +Sets how often global headers are re-inserted into the bytestream. +Default value is -1. This inserts headers at exponentially increasing locations +@math{2^23, 2^26, 2^29,...} etc. +Setting parameter in the range @math{[0,62]}, will insert headers periodically +after each @math{2^header_period} bytes at the next possible location. @end table @example diff --git a/libavformat/nut.h b/libavformat/nut.h index a990d3832e..c0928306c1 100644 --- a/libavformat/nut.h +++ b/libavformat/nut.h @@ -104,7 +104,8 @@ typedef struct NUTContext { int64_t last_syncpoint_pos; int64_t last_resync_pos; int header_count; // elision header count - int header_rep_count; // number of times headers written + int64_t header_rep_count; // number of times headers written + int header_period; // header insertion option AVRational *time_base; struct AVTreeNode *syncpoints; int sp_count; diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index 0646f72af2..5a775a92fe 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -988,11 +988,20 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt) data_size += sm_size; } + if (nut->header_period >= 0) { + if (avio_tell(bc) >> nut->header_period > nut->header_rep_count) { + ret = write_headers(s, bc); + nut->header_rep_count = avio_tell(bc) >> nut->header_period; + if (ret < 0) + goto fail; + } + } else { if (1LL << (20 + 3 * nut->header_rep_count) <= avio_tell(bc)) { ret = write_headers(s, bc); if (ret < 0) goto fail; } + } if (key_frame && !(nus->last_flags & FLAG_KEY)) store_sp = 1; @@ -1221,6 +1230,7 @@ static const AVOption options[] = { { "none", "Disable syncpoints, low overhead and unseekable", 0, AV_OPT_TYPE_CONST, {.i64 = NUT_PIPE}, INT_MIN, INT_MAX, E, "syncpoints" }, { "timestamped", "Extend syncpoints with a wallclock timestamp", 0, AV_OPT_TYPE_CONST, {.i64 = NUT_BROADCAST}, INT_MIN, INT_MAX, E, "syncpoints" }, { "write_index", "Write index", OFFSET(write_index), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, E, }, + { "header_period", "Header insertion parameter", OFFSET(header_period), AV_OPT_TYPE_INT, {.i64 =-1}, -1, 62, E, }, { NULL }, }; -- 2.28.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".