diff options
author | Stefano Sabatini <stefasab@gmail.com> | 2014-01-27 19:16:45 +0100 |
---|---|---|
committer | Stefano Sabatini <stefasab@gmail.com> | 2014-02-02 13:16:17 +0100 |
commit | 5871ee5072f725fce77cd51597ee91570de3743d (patch) | |
tree | d468a50fff2ad91786ff18475128203015dacc50 /libavformat | |
parent | a535d3952c66b93fc96752421da46ce2fd96158a (diff) | |
download | ffmpeg-5871ee5072f725fce77cd51597ee91570de3743d.tar.gz |
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.
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/avformat.h | 5 | ||||
-rw-r--r-- | libavformat/mux.c | 10 | ||||
-rw-r--r-- | libavformat/options_table.h | 1 | ||||
-rw-r--r-- | libavformat/version.h | 4 |
4 files changed, 18 insertions, 2 deletions
diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 76b0652cec..50b710816b 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1380,6 +1380,11 @@ typedef struct AVFormatContext { */ av_format_control_message control_message_cb; + /** + * Output timestamp offset, in microseconds. + * Muxing: set by user via AVOptions (NO direct access) + */ + int64_t output_ts_offset; } AVFormatContext; int av_format_get_probe_score(const AVFormatContext *s); diff --git a/libavformat/mux.c b/libavformat/mux.c index bd50191b87..70b60640a1 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -510,6 +510,16 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) { int ret, did_split; + if (s->output_ts_offset) { + AVStream *st = s->streams[pkt->stream_index]; + int64_t offset = av_rescale_q(s->output_ts_offset, AV_TIME_BASE_Q, st->time_base); + + if (pkt->dts != AV_NOPTS_VALUE) + pkt->dts += offset; + if (pkt->pts != AV_NOPTS_VALUE) + pkt->pts += offset; + } + if (s->avoid_negative_ts > 0) { AVStream *st = s->streams[pkt->stream_index]; int64_t offset = st->mux_ts_offset; diff --git a/libavformat/options_table.h b/libavformat/options_table.h index 32210422c9..b42a762738 100644 --- a/libavformat/options_table.h +++ b/libavformat/options_table.h @@ -78,6 +78,7 @@ static const AVOption avformat_options[] = { {"correct_ts_overflow", "correct single timestamp overflows", OFFSET(correct_ts_overflow), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, D}, {"flush_packets", "enable flushing of the I/O context after each packet", OFFSET(flush_packets), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E}, {"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}, +{"output_ts_offset", "set output timestamp offset", OFFSET(output_ts_offset), AV_OPT_TYPE_DURATION, {.i64 = 0}, -INT64_MAX, INT64_MAX, E}, {NULL}, }; diff --git a/libavformat/version.h b/libavformat/version.h index a052d3c32c..38945a57fd 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -30,8 +30,8 @@ #include "libavutil/version.h" #define LIBAVFORMAT_VERSION_MAJOR 55 -#define LIBAVFORMAT_VERSION_MINOR 28 -#define LIBAVFORMAT_VERSION_MICRO 101 +#define LIBAVFORMAT_VERSION_MINOR 29 +#define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ |