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

Michael Niedermayer michaelni at gmx.at
Mon Oct 22 05:13:50 CEST 2012


On Sun, Oct 21, 2012 at 02:21:32PM +0900, Heesuk Jung wrote:
> Fix indentation.
[...]
>  utils.c |   32 +++++++++++++++++++++++++++++---
>  1 file changed, 29 insertions(+), 3 deletions(-)
> 899a139c6d9a33211ebddafa54ec568fa7ef2551  0001-Wrong-duration-in-TS-container-Ticket-1836.patch
> From 2723ad65908531d136b828e4c9e615104a12beb8 Mon Sep 17 00:00:00 2001
> From: Heesuk Jung <heesuk.jung at lge.com>
> Date: Sun, 21 Oct 2012 13:21:23 +0900
> Subject: [PATCH] Wrong duration in TS container (Ticket #1836)
> 
> Libavformat somtimes get wrong duration in some TS conatiner.
> Please refer the problem description and file link in Ticket #1836.
> (http://ffmpeg.org/trac/ffmpeg/ticket/1836)
> 
> I have just modified 2 point as below.
> 
> 1. Duration determination considering time diff and file size / bit rate.
> 
> Duration is determined base on PTS time diff (end time - start ime) but
> sometime is unreasonably so big.
> I suggest that don't beleive duration based on PTS time diff
> if time diff is bigger than hueristic value (file size / average bit rate * 2).
> 
> 2. Change condition when estimate_timings_from_pts is called.
> 
> The estimate_timings_from_pts function is designed for MPEG-PS.
> And so I changed condition from MPEG-TS to MPEG-PS
> ---
>  libavformat/utils.c |   32 +++++++++++++++++++++++++++++---
>  1 files changed, 29 insertions(+), 3 deletions(-)
>  mode change 100644 => 100755 libavformat/utils.c
> 
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> old mode 100644
> new mode 100755
> index 745dcaa..d322907
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
[...]

> @@ -2077,8 +2100,11 @@ static void update_stream_timings(AVFormatContext *ic)
>  
>      if (start_time != INT64_MAX) {
>          ic->start_time = start_time;
> -        if (end_time != INT64_MIN)
> -            duration = FFMAX(duration, end_time - start_time);
> +        if (end_time != INT64_MIN) {
> +            if (valid_duration_from_pts(start_time, end_time, avio_size(ic->pb), ic->bit_rate)) {
> +                duration = FFMAX(duration, end_time - start_time);
> +            }
> +        }
>      }
>      if (duration != INT64_MIN && duration > 0 && ic->duration == AV_NOPTS_VALUE) {
>          ic->duration = duration;

this makes stream durations and file duration inconsistent


> @@ -2233,7 +2259,7 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset)
>      }
>  
>      if ((!strcmp(ic->iformat->name, "mpeg") ||
> -         !strcmp(ic->iformat->name, "mpegts")) &&
> +         !strcmp(ic->iformat->name, "mpegps")) &&

there is no ic->iformat->name == "mpegps"

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121022/922d7bec/attachment.asc>


More information about the ffmpeg-devel mailing list