[FFmpeg-devel] [PATCH] Wrong duration in TS container (Ticket #1836)

Heesuk Jung heesuk.jung at lge.com
Fri Nov 16 09:21:39 CET 2012


Hi

> It appears your mailer has eaten your patch, it looks like it cannot be
applied.

Thanks for prompt response and update again.
If you can not adapt patch, please refer the attached file.

>From aac495a25fc0ceb17eabbcd73c6519b7dcb9da30 Mon Sep 17 00:00:00 2001
From: Heesuk Jung <heesuk.jung at lge.com>
Date: Fri, 16 Nov 2012 16:26:04 +0900
Subject: [PATCH] Wrong duration in TS container (Ticket #1836)

Sometimes TS container file has unreasonbly big PTS in last frame.
In this case, we use previous last PTS value to decide stream dueation.

Fix 2nd promlematic file cas in Ticket #1836
link : https://docs.google.com/open?id=0B6r7ZfWFIypCNFVuWHowMFBBN0E
---
 libavformat/utils.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 4072ac8..fb55477 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2161,6 +2161,7 @@ static void
estimate_timings_from_bit_rate(AVFormatContext *ic)
 
 #define DURATION_MAX_READ_SIZE 250000LL
 #define DURATION_MAX_RETRY 4
+#define DURATION_MULTIPLE_LIMIT 8
 
 /* only usable for MPEG-PS streams */
 static void estimate_timings_from_pts(AVFormatContext *ic, int64_t
old_offset)
@@ -2170,6 +2171,7 @@ static void estimate_timings_from_pts(AVFormatContext
*ic, int64_t old_offset)
     int read_size, i, ret;
     int64_t end_time;
     int64_t filesize, offset, duration;
+    int64_t ref_duration, pre_duration;
     int retry=0;
 
     /* flush packet queue */
@@ -2190,6 +2192,7 @@ static void estimate_timings_from_pts(AVFormatContext
*ic, int64_t old_offset)
     /* XXX: may need to support wrapping */
     filesize = ic->pb ? avio_size(ic->pb) : 0;
     end_time = AV_NOPTS_VALUE;
+    ref_duration = AV_NOPTS_VALUE;
     do{
         offset = filesize - (DURATION_MAX_READ_SIZE<<retry);
         if (offset < 0)
@@ -2219,8 +2222,16 @@ static void estimate_timings_from_pts(AVFormatContext
*ic, int64_t old_offset)
                 if (duration < 0)
                     duration += 1LL<<st->pts_wrap_bits;
                 if (duration > 0) {
-                    if (st->duration == AV_NOPTS_VALUE || st->duration <
duration)
+                    if (st->duration == AV_NOPTS_VALUE || st->duration <
duration) {
+                        pre_duration = st->duration;
                         st->duration = duration;
+                        if (ref_duration == AV_NOPTS_VALUE) {
+                            ref_duration = st->duration;
+                        } else if (st->duration/DURATION_MULTIPLE_LIMIT >
ref_duration) {
+                            st->duration = pre_duration;
+                            break;
+                        }
+                    }
                 }
             }
             av_free_packet(pkt);
-- 
1.7.0.4


-----Original Message-----
From: ffmpeg-devel-bounces at ffmpeg.org
[mailto:ffmpeg-devel-bounces at ffmpeg.org] On Behalf Of Carl Eugen Hoyos
Sent: Friday, November 16, 2012 5:14 PM
To: ffmpeg-devel at ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH] Wrong duration in TS container (Ticket
#1836)

Heesuk Jung <heesuk.jung <at> lge.com> writes:

> Thanks for comment and update new one.

It appears your mailer has eaten your patch, it looks like it cannot be
applied.

Carl Eugen

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel at ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Wrong-duration-in-TS-container-Ticket-1836.patch
Type: application/octet-stream
Size: 3360 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121116/b1b0bbdd/attachment.obj>


More information about the ffmpeg-devel mailing list