[FFmpeg-cvslog] lavf: add use_wallclock_as_timestamps

Michael Niedermayer git at videolan.org
Sat Aug 18 19:24:42 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Aug 17 00:08:51 2012 +0200| [28ff17fa9761706ec5f07c07ce9ff04816536749] | committer: Michael Niedermayer

lavf: add use_wallclock_as_timestamps

This may fix Ticket730

Reviewed-by: Nicolas George <nicolas.george at normalesup.org>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavformat/avformat.h      |    8 ++++++++
 libavformat/options_table.h |    1 +
 libavformat/utils.c         |    3 +++
 3 files changed, 12 insertions(+)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 05b4fc7..b635ae7 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1100,6 +1100,14 @@ typedef struct AVFormatContext {
      */
     int max_chunk_size;
 
+    /**
+     * forces the use of wallclock timestamps as pts/dts of packets
+     * This has undefined results in the presence of B frames.
+     * - encoding: unused
+     * - decoding: Set by user via AVOptions (NO direct access)
+     */
+    int use_wallclock_as_timestamps;
+
     /*****************************************************************
      * All fields below this line are not part of the public API. They
      * may not be used outside of libavformat and can be changed and
diff --git a/libavformat/options_table.h b/libavformat/options_table.h
index 9bc0329..fd55df8 100644
--- a/libavformat/options_table.h
+++ b/libavformat/options_table.h
@@ -70,6 +70,7 @@ static const AVOption options[]={
 {"careful",    "consider things that violate the spec and have not been seen in the wild as errors", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_CAREFUL }, INT_MIN, INT_MAX, D, "err_detect"},
 {"compliant",  "consider all spec non compliancies as errors", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_COMPLIANT }, INT_MIN, INT_MAX, D, "err_detect"},
 {"aggressive", "consider things that a sane encoder shouldnt do as an error", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_AGGRESSIVE }, INT_MIN, INT_MAX, D, "err_detect"},
+{"use_wallclock_as_timestamps", "use wallclock as timestamps", OFFSET(use_wallclock_as_timestamps), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX-1, D},
 {NULL},
 };
 
diff --git a/libavformat/utils.c b/libavformat/utils.c
index d166d08..af1c281 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -776,6 +776,9 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
             if(s->subtitle_codec_id)st->codec->codec_id= s->subtitle_codec_id;
             break;
         }
+        /* TODO: audio: time filter; video: frame reordering (pts != dts) */
+        if (s->use_wallclock_as_timestamps)
+            pkt->dts = pkt->pts = av_rescale_q(av_gettime(), AV_TIME_BASE_Q, st->time_base);
 
         if(!pktl && st->request_probe <= 0)
             return ret;



More information about the ffmpeg-cvslog mailing list