@@ -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
@@ -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;
@@ -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 },
};