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
15 15
16API changes, most recent first:16API changes, most recent first:
17 17
182014-02-02 - xxxxxxx - lavf 55.29.100 - avformat.h
19 Add output_ts_offset muxing option to AVFormatContext.
20
182014-01-27 - 102bd64 - lavd 55.7.100 - avdevice.h212014-01-27 - 102bd64 - lavd 55.7.100 - avdevice.h
19 lavf 55.28.100 - avformat.h22 lavf 55.28.100 - avformat.h
20 Add avdevice_dev_to_app_control_message() function.23 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
148Flush the underlying I/O stream after each packet. Default 1 enables it, and148Flush the underlying I/O stream after each packet. Default 1 enables it, and
149has the effect of reducing the latency; 0 disables it and may slightly149has the effect of reducing the latency; 0 disables it and may slightly
150increase performance in some cases.150increase performance in some cases.
151
152@item output_ts_offset @var{offset} (@emph{output})
153Set the output time offset.
154
155@var{offset} must be a time duration specification,
156see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
157
158The offset is added by the muxer to the output timestamps.
159
160Specifying a positive offset means that the corresponding streams are
161delayed bt the time duration specified in @var{offset}. Default value
162is @code{0} (meaning that no offset is applied).
151@end table163@end table
152 164
153@c man end FORMAT OPTIONS165@c man end FORMAT OPTIONS
libavformat/avformat.h+5−0
@@ -1380,6 +1380,11 @@ typedef struct AVFormatContext { · 1379 unmodified lines
1380 */1380 */
1381 av_format_control_message control_message_cb;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} AVFormatContext;1388} AVFormatContext;
1384 1389
1385int av_format_get_probe_score(const AVFormatContext *s);1390int 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
510{510{
511 int ret, did_split;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 if (s->avoid_negative_ts > 0) {523 if (s->avoid_negative_ts > 0) {
514 AVStream *st = s->streams[pkt->stream_index];524 AVStream *st = s->streams[pkt->stream_index];
515 int64_t offset = st->mux_ts_offset;525 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
78{"correct_ts_overflow", "correct single timestamp overflows", OFFSET(correct_ts_overflow), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, D},78{"correct_ts_overflow", "correct single timestamp overflows", OFFSET(correct_ts_overflow), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, D},
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},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{"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},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{NULL},82{NULL},
82};83};
83 84
libavformat/version.h+2−2
@@ -30,8 +30,8 @@ · 29 unmodified lines
30#include "libavutil/version.h"30#include "libavutil/version.h"
31 31
32#define LIBAVFORMAT_VERSION_MAJOR 5532#define LIBAVFORMAT_VERSION_MAJOR 55
33#define LIBAVFORMAT_VERSION_MINOR 2833#define LIBAVFORMAT_VERSION_MINOR 29
34#define LIBAVFORMAT_VERSION_MICRO 10134#define LIBAVFORMAT_VERSION_MICRO 100
35 35
36#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \36#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
37 LIBAVFORMAT_VERSION_MINOR, \37 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