[FFmpeg-cvslog] avformat/mux: add ff_get_muxer_ts_offset()

James Almer git at videolan.org
Sat Feb 13 18:24:07 EET 2021


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Mon Feb  8 18:30:47 2021 -0300| [93e2fa933f1625f488a2d88f9d50254ef13401d2] | committer: James Almer

avformat/mux: add ff_get_muxer_ts_offset()

Will be useful in the next patch

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=93e2fa933f1625f488a2d88f9d50254ef13401d2
---

 libavformat/internal.h |  1 +
 libavformat/mux.c      | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/libavformat/internal.h b/libavformat/internal.h
index d0db331b96..33ece6b172 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -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);
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 84c56ac6ba..ae46844c66 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -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)
 {



More information about the ffmpeg-cvslog mailing list