Browse Source

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.
tags/n2.2-rc1
Stefano Sabatini 12 years ago
parent
commit
5871ee5072
6 changed files with 33 additions and 2 deletions
  1. +3
    -0
      doc/APIchanges
  2. +12
    -0
      doc/formats.texi
  3. +5
    -0
      libavformat/avformat.h
  4. +10
    -0
      libavformat/mux.c
  5. +1
    -0
      libavformat/options_table.h
  6. +2
    -2
      libavformat/version.h

+ 3
- 0
doc/APIchanges View File

@@ -15,6 +15,9 @@ libavutil: 2012-10-22

API changes, most recent first:

2014-02-02 - xxxxxxx - lavf 55.29.100 - avformat.h
Add output_ts_offset muxing option to AVFormatContext.

2014-01-27 - 102bd64 - lavd 55.7.100 - avdevice.h
lavf 55.28.100 - avformat.h
Add avdevice_dev_to_app_control_message() function.


+ 12
- 0
doc/formats.texi View File

@@ -148,6 +148,18 @@ Correct single timestamp overflows if set to 1. Default is 1.
Flush the underlying I/O stream after each packet. Default 1 enables it, and
has the effect of reducing the latency; 0 disables it and may slightly
increase performance in some cases.

@item output_ts_offset @var{offset} (@emph{output})
Set the output time offset.

@var{offset} must be a time duration specification,
see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.

The offset is added by the muxer to the output timestamps.

Specifying a positive offset means that the corresponding streams are
delayed bt the time duration specified in @var{offset}. Default value
is @code{0} (meaning that no offset is applied).
@end table

@c man end FORMAT OPTIONS


+ 5
- 0
libavformat/avformat.h View File

@@ -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);


+ 10
- 0
libavformat/mux.c View File

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


+ 1
- 0
libavformat/options_table.h View File

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



+ 2
- 2
libavformat/version.h View File

@@ -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, \


Loading…
Cancel
Save