[FFmpeg-devel] [PATCH 1/2] avformat/segment: remove initial_offset option from segment.c

Steven Liu lingjiujianke at gmail.com
Thu Sep 8 16:33:02 EEST 2016


ffmpeg have a generic solution working with all muxer named
output_ts_offset

Signed-off-by: LiuQi <liuqi at gosun.com>
---
 libavformat/segment.c | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/libavformat/segment.c b/libavformat/segment.c
index bf29ef8..2fc380e 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -114,7 +114,6 @@ typedef struct SegmentContext {
     char *header_filename;  ///< filename to write the output header to

     int reset_timestamps;  ///< reset timestamps at the begin of each
segment
-    int64_t initial_offset;    ///< initial timestamps offset, expressed
in microseconds
     char *reference_stream_specifier; ///< reference stream specifier
     int   reference_stream_index;
     int   break_non_keyframes;
@@ -802,7 +801,7 @@ static int seg_write_packet(AVFormatContext *s,
AVPacket *pkt)
 {
     SegmentContext *seg = s->priv_data;
     AVStream *st = s->streams[pkt->stream_index];
-    int64_t end_pts = INT64_MAX, offset;
+    int64_t end_pts = INT64_MAX;
     int start_frame = INT_MAX;
     int ret;
     struct tm ti;
@@ -888,19 +887,7 @@ calc_times:
            av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base),
            av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &st->time_base));

-    /* compute new timestamps */
-    offset = av_rescale_q(seg->initial_offset - (seg->reset_timestamps ?
seg->cur_entry.start_pts : 0),
-                          AV_TIME_BASE_Q, st->time_base);
-    if (pkt->pts != AV_NOPTS_VALUE)
-        pkt->pts += offset;
-    if (pkt->dts != AV_NOPTS_VALUE)
-        pkt->dts += offset;
-
-    av_log(s, AV_LOG_DEBUG, " -> pts:%s pts_time:%s dts:%s dts_time:%s\n",
-           av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base),
-           av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &st->time_base));
-
-    ret = ff_write_chained(seg->avf, pkt->stream_index, pkt, s,
seg->initial_offset || seg->reset_timestamps);
+    ret = ff_write_chained(seg->avf, pkt->stream_index, pkt, s,
seg->reset_timestamps);

 fail:
     if (pkt->stream_index == seg->reference_stream_index) {
@@ -998,7 +985,6 @@ static const AVOption options[] = {
     { "individual_header_trailer", "write header/trailer to each segment",
OFFSET(individual_header_trailer), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, E },
     { "write_header_trailer", "write a header to the first segment and a
trailer to the last one", OFFSET(write_header_trailer), AV_OPT_TYPE_BOOL,
{.i64 = 1}, 0, 1, E },
     { "reset_timestamps", "reset timestamps at the begin of each segment",
OFFSET(reset_timestamps), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, E },
-    { "initial_offset", "set initial timestamp offset",
OFFSET(initial_offset), AV_OPT_TYPE_DURATION, {.i64 = 0}, -INT64_MAX,
INT64_MAX, E },
     { "write_empty_segments", "allow writing empty 'filler' segments",
OFFSET(write_empty), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, E },
     { NULL },
 };
-- 
2.7.4 (Apple Git-66)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-avformat-segment-remove-initial_offset-option-from-s.patch
Type: application/octet-stream
Size: 3211 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160908/71472bcc/attachment.obj>


More information about the ffmpeg-devel mailing list