History

lavf: add output_ts_offset option to AVFormatContext

This option can be generally useful to set an output offset, needed when setting an absolute index in the output.

Stefano Sabatini committed 12 years ago

Commit 5871ee51 parent a535d396 files · +33 −2Browse files

Unified · Split

6 files
  1. doc/APIchanges +3 −0
  2. doc/formats.texi +12 −0
  3. libavformat/avformat.h +5 −0
  4. libavformat/mux.c +10 −0
  5. libavformat/options_table.h +1 −0
  6. libavformat/version.h +2 −2
doc/APIchanges+3−0
@@ -15,6 +15,9 @@ libavutil: 2012-10-22 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2014-02-02 - xxxxxxx - lavf 55.29.100 - avformat.h
19+ Add output_ts_offset muxing option to AVFormatContext.
20+
1821 2014-01-27 - 102bd64 - lavd 55.7.100 - avdevice.h
1922 lavf 55.28.100 - avformat.h
2023 Add avdevice_dev_to_app_control_message() function.
doc/formats.texi+12−0
@@ -148,6 +148,18 @@ Correct single timestamp overflows if set to 1. Default is 1. · 147 unmodified lines
148148 Flush the underlying I/O stream after each packet. Default 1 enables it, and
149149 has the effect of reducing the latency; 0 disables it and may slightly
150150 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).
151163 @end table
152164
153165 @c man end FORMAT OPTIONS
libavformat/avformat.h+5−0
@@ -1380,6 +1380,11 @@ typedef struct AVFormatContext { · 1379 unmodified lines
13801380 */
13811381 av_format_control_message control_message_cb;
13821382
1383+ /**
1384+ * Output timestamp offset, in microseconds.
1385+ * Muxing: set by user via AVOptions (NO direct access)
1386+ */
1387+ int64_t output_ts_offset;
13831388 } AVFormatContext;
13841389
13851390 int av_format_get_probe_score(const AVFormatContext *s);
libavformat/mux.c+10−0
@@ -510,6 +510,16 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) · 509 unmodified lines
510510 {
511511 int ret, did_split;
512512
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+
513523 if (s->avoid_negative_ts > 0) {
514524 AVStream *st = s->streams[pkt->stream_index];
515525 int64_t offset = st->mux_ts_offset;
libavformat/options_table.h+1−0
@@ -78,6 +78,7 @@ static const AVOption avformat_options[] = { · 77 unmodified lines
7878 {"correct_ts_overflow", "correct single timestamp overflows", OFFSET(correct_ts_overflow), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, D},
7979 {"flush_packets", "enable flushing of the I/O context after each packet", OFFSET(flush_packets), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E},
8080 {"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},
8182 {NULL},
8283 };
8384
libavformat/version.h+2−2
@@ -30,8 +30,8 @@ · 29 unmodified lines
3030 #include "libavutil/version.h"
3131
3232 #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
3535
3636 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
3737 LIBAVFORMAT_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t