[FFmpeg-devel] [PATCH] Fix HTTP Live segmenter in combination with -copyts

Michael Niedermayer michaelni at gmx.at
Sat Sep 14 23:10:16 CEST 2013


On Thu, Sep 12, 2013 at 10:43:38AM +0200, Jeroen Ost wrote:
> With correct file extension this time.
> 
> On Wed, Sep 11, 2013 at 10:09 AM, Jeroen Ost <jeroen.ost at gmail.com> wrote:
> > The live segmenter on mpegts timestamps works fine when timestamps are
> > numbered from 0 (= default). When used with -copyts, the segmenter
> > creates a new segment every keyframe because it doesn't take the
> > initial pts into account. This patch fixes that.

>  segment.c |    6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> a2c66c6ae8c5d016e9e4b2309361b326faa93a39  fix-httplive-segmenter-with-copyts.diff
> diff --git a/libavformat/segment.c b/libavformat/segment.c
> index f9289ec..842f42a 100644
> --- a/libavformat/segment.c
> +++ b/libavformat/segment.c
> @@ -100,6 +100,7 @@ typedef struct {
>      SegmentListEntry *segment_list_entries_end;
>  
>      int is_first_pkt;      ///< tells if it is the first packet in the segment
> +    int64_t startpts;
>  } SegmentContext;
>  
>  static void print_csv_escaped_str(AVIOContext *ctx, const char *str)
> @@ -647,7 +648,10 @@ static int seg_write_packet(AVFormatContext *s, AVPacket *pkt)
>          start_frame = seg->segment_count <= seg->nb_frames ?
>              seg->frames[seg->segment_count-1] : INT_MAX;
>      } else {
> -        end_pts = seg->time * seg->segment_count;
> +        if (seg->is_first_pkt) {
> +                seg->startpts = av_rescale_q(pkt->pts, st->time_base, AV_TIME_BASE_Q);
> +        }

this is missing handling of the pts == AV_NOPTS_VALUE case or am
i missing something why this cannot occur ?

[...]

Thanks

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.
-------------- 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/20130914/f1f1a3a1/attachment.asc>


More information about the ffmpeg-devel mailing list