This option can be generally useful to set an output offset, needed when setting an absolute index in the output.
Unified · Split
| @@ -15,6 +15,9 @@ libavutil: 2012-10-22 · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | API changes, most recent first: |
| 17 | 17 | |
| 18 | +2014-02-02 - xxxxxxx - lavf 55.29.100 - avformat.h | |
| 19 | + Add output_ts_offset muxing option to AVFormatContext. | |
| 20 | + | |
| 18 | 21 | 2014-01-27 - 102bd64 - lavd 55.7.100 - avdevice.h |
| 19 | 22 | lavf 55.28.100 - avformat.h |
| 20 | 23 | Add avdevice_dev_to_app_control_message() function. |
| @@ -148,6 +148,18 @@ Correct single timestamp overflows if set to 1. Default is 1. · 147 unmodified lines | ||
| 148 | 148 | Flush the underlying I/O stream after each packet. Default 1 enables it, and |
| 149 | 149 | has the effect of reducing the latency; 0 disables it and may slightly |
| 150 | 150 | increase performance in some cases. |
| 151 | + | |
| 152 | +@item output_ts_offset @var{offset} (@emph{output}) | |
| 153 | +Set the output time offset. | |
| 154 | + | |
| 155 | +@var{offset} must be a time duration specification, | |
| 156 | +see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}. | |
| 157 | + | |
| 158 | +The offset is added by the muxer to the output timestamps. | |
| 159 | + | |
| 160 | +Specifying a positive offset means that the corresponding streams are | |
| 161 | +delayed bt the time duration specified in @var{offset}. Default value | |
| 162 | +is @code{0} (meaning that no offset is applied). | |
| 151 | 163 | @end table |
| 152 | 164 | |
| 153 | 165 | @c man end FORMAT OPTIONS |
| @@ -1380,6 +1380,11 @@ typedef struct AVFormatContext { · 1379 unmodified lines | ||
| 1380 | 1380 | */ |
| 1381 | 1381 | av_format_control_message control_message_cb; |
| 1382 | 1382 | |
| 1383 | + /** | |
| 1384 | + * Output timestamp offset, in microseconds. | |
| 1385 | + * Muxing: set by user via AVOptions (NO direct access) | |
| 1386 | + */ | |
| 1387 | + int64_t output_ts_offset; | |
| 1383 | 1388 | } AVFormatContext; |
| 1384 | 1389 | |
| 1385 | 1390 | int av_format_get_probe_score(const AVFormatContext *s); |
| @@ -510,6 +510,16 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) · 509 unmodified lines | ||
| 510 | 510 | { |
| 511 | 511 | int ret, did_split; |
| 512 | 512 | |
| 513 | + if (s->output_ts_offset) { | |
| 514 | + AVStream *st = s->streams[pkt->stream_index]; | |
| 515 | + int64_t offset = av_rescale_q(s->output_ts_offset, AV_TIME_BASE_Q, st->time_base); | |
| 516 | + | |
| 517 | + if (pkt->dts != AV_NOPTS_VALUE) | |
| 518 | + pkt->dts += offset; | |
| 519 | + if (pkt->pts != AV_NOPTS_VALUE) | |
| 520 | + pkt->pts += offset; | |
| 521 | + } | |
| 522 | + | |
| 513 | 523 | if (s->avoid_negative_ts > 0) { |
| 514 | 524 | AVStream *st = s->streams[pkt->stream_index]; |
| 515 | 525 | int64_t offset = st->mux_ts_offset; |
| @@ -78,6 +78,7 @@ static const AVOption avformat_options[] = { · 77 unmodified lines | ||
| 78 | 78 | {"correct_ts_overflow", "correct single timestamp overflows", OFFSET(correct_ts_overflow), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, D}, |
| 79 | 79 | {"flush_packets", "enable flushing of the I/O context after each packet", OFFSET(flush_packets), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E}, |
| 80 | 80 | {"metadata_header_padding", "set number of bytes to be written as padding in a metadata header", OFFSET(metadata_header_padding), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, E}, |
| 81 | +{"output_ts_offset", "set output timestamp offset", OFFSET(output_ts_offset), AV_OPT_TYPE_DURATION, {.i64 = 0}, -INT64_MAX, INT64_MAX, E}, | |
| 81 | 82 | {NULL}, |
| 82 | 83 | }; |
| 83 | 84 | |
| @@ -30,8 +30,8 @@ · 29 unmodified lines | ||
| 30 | 30 | #include "libavutil/version.h" |
| 31 | 31 | |
| 32 | 32 | #define LIBAVFORMAT_VERSION_MAJOR 55 |
| 33 | −#define LIBAVFORMAT_VERSION_MINOR 28 | |
| 34 | −#define LIBAVFORMAT_VERSION_MICRO 101 | |
| 33 | +#define LIBAVFORMAT_VERSION_MINOR 29 | |
| 34 | +#define LIBAVFORMAT_VERSION_MICRO 100 | |
| 35 | 35 | |
| 36 | 36 | #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ |
| 37 | 37 | LIBAVFORMAT_VERSION_MINOR, \ |