]> git.sesse.net Git - ffmpeg/commitdiff
avformat/mux: add ff_get_muxer_ts_offset()
authorJames Almer <jamrial@gmail.com>
Mon, 8 Feb 2021 21:30:47 +0000 (18:30 -0300)
committerJames Almer <jamrial@gmail.com>
Sat, 13 Feb 2021 16:01:48 +0000 (13:01 -0300)
Will be useful in the next patch

Signed-off-by: James Almer <jamrial@gmail.com>
libavformat/internal.h
libavformat/mux.c

index d0db331b96d5eb9dde9757b33fb4221b047c8d95..33ece6b17221981002396f206dc60e99a93fd6a0 100644 (file)
@@ -874,6 +874,7 @@ int ff_bprint_to_codecpar_extradata(AVCodecParameters *par, struct AVBPrint *buf
 int ff_interleaved_peek(AVFormatContext *s, int stream,
                         AVPacket *pkt, int add_offset);
 
+int ff_get_muxer_ts_offset(AVFormatContext *s, int stream_index, int64_t *offset);
 
 int ff_lock_avformat(void);
 int ff_unlock_avformat(void);
index 84c56ac6bab8a6d34b0c253a6b580a7f9fb2819f..ae46844c66c80bb22848b890a3e916aec63a1ae5 100644 (file)
@@ -1046,6 +1046,22 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
     }
 }
 
+int ff_get_muxer_ts_offset(AVFormatContext *s, int stream_index, int64_t *offset)
+{
+    AVStream *st;
+
+    if (stream_index < 0 || stream_index >= s->nb_streams)
+        return AVERROR(EINVAL);
+
+    st = s->streams[stream_index];
+    *offset = st->internal->mux_ts_offset;
+
+    if (s->output_ts_offset)
+        *offset += av_rescale_q(s->output_ts_offset, AV_TIME_BASE_Q, st->time_base);
+
+    return 0;
+}
+
 int ff_interleaved_peek(AVFormatContext *s, int stream,
                         AVPacket *pkt, int add_offset)
 {