Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: implement initial_offset

2016-09-08 Thread Michael Niedermayer
On Thu, Sep 08, 2016 at 08:42:05PM +0800, Steven Liu wrote:
> 2016-09-08 20:31 GMT+08:00 Michael Niedermayer :
> 
> > On Thu, Sep 08, 2016 at 05:10:14AM -0700, Aman Gupta wrote:
> > > On Thu, Sep 8, 2016 at 2:55 AM, Steven Liu 
> > wrote:
> > >
> > > > 2016-09-08 17:46 GMT+08:00 Michael Niedermayer  > >:
> > > >
> > > > > On Thu, Sep 08, 2016 at 10:47:42AM +0900, Aman Gupta wrote:
> > > > > > From: Aman Gupta 
> > > > > >
> > > > > > ---
> > > > > >  doc/muxers.texi  |  4 
> > > > > >  libavformat/hlsenc.c | 13 +++--
> > > > > >  2 files changed, 15 insertions(+), 2 deletions(-)
> > > > >
> > > > > Isnt this redundant with
> > > > > -output_ts_offset
> > > > > ?
> > > > > or how do they differ ?
> > > > >
> > > > > [...]
> > > > > --
> > > > > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC7
> > 87040B0FAB
> > > > >
> > > > > Into a blind darkness they enter who follow after the Ignorance,
> > > > > they as if into a greater darkness enter who devote themselves
> > > > > to the Knowledge alone. -- Isha Upanishad
> > > > >
> > > > >
> > > > >
> > > > Maybe just copy the code from segment.c to hlsenc.c .
> > > >
> > >
> > > Yes, I copied directly from segment.c because I wanted the same feature
> > in
> > > the hls encoder.
> > >
> > > Was not aware of -output_ts_offset. Perhaps that supersedes the
> > > -initial_offset option?
> >
> > does output_ts_offset work as replacement for initial_offset ?
> > a generic solution working with all muxer would be better/simper
> >
> > [...]
> > --
> > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> >
> > The bravest are surely those who have the clearest vision
> > of what is before them, glory and danger alike, and yet
> > notwithstanding go out to meet it. -- Thucydides
> >
> >
> Aha, new version have output_ts_offset in mux.c, perhaps this option should
> be ignored.
> 

> And segment.c give a deprecated message and replace by output_ts_offset?

yes if t works

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: implement initial_offset

2016-09-08 Thread Steven Liu
2016-09-08 20:31 GMT+08:00 Michael Niedermayer :

> On Thu, Sep 08, 2016 at 05:10:14AM -0700, Aman Gupta wrote:
> > On Thu, Sep 8, 2016 at 2:55 AM, Steven Liu 
> wrote:
> >
> > > 2016-09-08 17:46 GMT+08:00 Michael Niedermayer  >:
> > >
> > > > On Thu, Sep 08, 2016 at 10:47:42AM +0900, Aman Gupta wrote:
> > > > > From: Aman Gupta 
> > > > >
> > > > > ---
> > > > >  doc/muxers.texi  |  4 
> > > > >  libavformat/hlsenc.c | 13 +++--
> > > > >  2 files changed, 15 insertions(+), 2 deletions(-)
> > > >
> > > > Isnt this redundant with
> > > > -output_ts_offset
> > > > ?
> > > > or how do they differ ?
> > > >
> > > > [...]
> > > > --
> > > > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC7
> 87040B0FAB
> > > >
> > > > Into a blind darkness they enter who follow after the Ignorance,
> > > > they as if into a greater darkness enter who devote themselves
> > > > to the Knowledge alone. -- Isha Upanishad
> > > >
> > > >
> > > >
> > > Maybe just copy the code from segment.c to hlsenc.c .
> > >
> >
> > Yes, I copied directly from segment.c because I wanted the same feature
> in
> > the hls encoder.
> >
> > Was not aware of -output_ts_offset. Perhaps that supersedes the
> > -initial_offset option?
>
> does output_ts_offset work as replacement for initial_offset ?
> a generic solution working with all muxer would be better/simper
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> The bravest are surely those who have the clearest vision
> of what is before them, glory and danger alike, and yet
> notwithstanding go out to meet it. -- Thucydides
>
>
Aha, new version have output_ts_offset in mux.c, perhaps this option should
be ignored.

And segment.c give a deprecated message and replace by output_ts_offset?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: implement initial_offset

2016-09-08 Thread Michael Niedermayer
On Thu, Sep 08, 2016 at 05:10:14AM -0700, Aman Gupta wrote:
> On Thu, Sep 8, 2016 at 2:55 AM, Steven Liu  wrote:
> 
> > 2016-09-08 17:46 GMT+08:00 Michael Niedermayer :
> >
> > > On Thu, Sep 08, 2016 at 10:47:42AM +0900, Aman Gupta wrote:
> > > > From: Aman Gupta 
> > > >
> > > > ---
> > > >  doc/muxers.texi  |  4 
> > > >  libavformat/hlsenc.c | 13 +++--
> > > >  2 files changed, 15 insertions(+), 2 deletions(-)
> > >
> > > Isnt this redundant with
> > > -output_ts_offset
> > > ?
> > > or how do they differ ?
> > >
> > > [...]
> > > --
> > > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> > >
> > > Into a blind darkness they enter who follow after the Ignorance,
> > > they as if into a greater darkness enter who devote themselves
> > > to the Knowledge alone. -- Isha Upanishad
> > >
> > >
> > >
> > Maybe just copy the code from segment.c to hlsenc.c .
> >
> 
> Yes, I copied directly from segment.c because I wanted the same feature in
> the hls encoder.
> 
> Was not aware of -output_ts_offset. Perhaps that supersedes the
> -initial_offset option?

does output_ts_offset work as replacement for initial_offset ?
a generic solution working with all muxer would be better/simper

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: implement initial_offset

2016-09-08 Thread Aman Gupta
On Thu, Sep 8, 2016 at 2:55 AM, Steven Liu  wrote:

> 2016-09-08 17:46 GMT+08:00 Michael Niedermayer :
>
> > On Thu, Sep 08, 2016 at 10:47:42AM +0900, Aman Gupta wrote:
> > > From: Aman Gupta 
> > >
> > > ---
> > >  doc/muxers.texi  |  4 
> > >  libavformat/hlsenc.c | 13 +++--
> > >  2 files changed, 15 insertions(+), 2 deletions(-)
> >
> > Isnt this redundant with
> > -output_ts_offset
> > ?
> > or how do they differ ?
> >
> > [...]
> > --
> > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> >
> > Into a blind darkness they enter who follow after the Ignorance,
> > they as if into a greater darkness enter who devote themselves
> > to the Knowledge alone. -- Isha Upanishad
> >
> >
> >
> Maybe just copy the code from segment.c to hlsenc.c .
>

Yes, I copied directly from segment.c because I wanted the same feature in
the hls encoder.

Was not aware of -output_ts_offset. Perhaps that supersedes the
-initial_offset option?

Aman



> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: implement initial_offset

2016-09-08 Thread Steven Liu
2016-09-08 17:46 GMT+08:00 Michael Niedermayer :

> On Thu, Sep 08, 2016 at 10:47:42AM +0900, Aman Gupta wrote:
> > From: Aman Gupta 
> >
> > ---
> >  doc/muxers.texi  |  4 
> >  libavformat/hlsenc.c | 13 +++--
> >  2 files changed, 15 insertions(+), 2 deletions(-)
>
> Isnt this redundant with
> -output_ts_offset
> ?
> or how do they differ ?
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Into a blind darkness they enter who follow after the Ignorance,
> they as if into a greater darkness enter who devote themselves
> to the Knowledge alone. -- Isha Upanishad
>
>
>
Maybe just copy the code from segment.c to hlsenc.c .
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: implement initial_offset

2016-09-08 Thread Michael Niedermayer
On Thu, Sep 08, 2016 at 10:47:42AM +0900, Aman Gupta wrote:
> From: Aman Gupta 
> 
> ---
>  doc/muxers.texi  |  4 
>  libavformat/hlsenc.c | 13 +++--
>  2 files changed, 15 insertions(+), 2 deletions(-)

Isnt this redundant with
-output_ts_offset
?
or how do they differ ?

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: implement initial_offset

2016-09-07 Thread Steven Liu
2016-09-08 9:47 GMT+08:00 Aman Gupta :

> From: Aman Gupta 
>
> ---
>  doc/muxers.texi  |  4 
>  libavformat/hlsenc.c | 13 +++--
>  2 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index fd7ee50..e88dbf8 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -389,6 +389,10 @@ to @var{wrap}.
>  Start the playlist sequence number from @var{number}. Default value is
>  0.
>
> +@item initial_offset @var{offset}
> +Specify timestamp offset to apply to the output packet timestamps. The
> +argument must be a time duration specification, and defaults to 0.
> +
>  @item hls_allow_cache @var{allowcache}
>  Explicitly set whether the client MAY (1) or MUST NOT (0) cache media
> segments.
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 1846d9d..be58db8 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -90,6 +90,7 @@ typedef struct HLSContext {
>  uint32_t pl_type;  // enum PlaylistType
>  char *segment_filename;
>
> +int64_t initial_offset; ///< initial timestamps offset, expressed in
> microseconds
>  int use_localtime;  ///< flag to expand filename with localtime
>  int use_localtime_mkdir;///< flag to mkdir dirname in timebased
> filename
>  int allowcache;
> @@ -795,7 +796,7 @@ static int hls_write_packet(AVFormatContext *s,
> AVPacket *pkt)
>  HLSContext *hls = s->priv_data;
>  AVFormatContext *oc = NULL;
>  AVStream *st = s->streams[pkt->stream_index];
> -int64_t end_pts = hls->recording_time * hls->number;
> +int64_t end_pts = hls->recording_time * hls->number, offset;
>  int is_ref_pkt = 1;
>  int ret, can_split = 1;
>  int stream_index = 0;
> @@ -871,7 +872,14 @@ static int hls_write_packet(AVFormatContext *s,
> AVPacket *pkt)
>  return ret;
>  }
>
> -ret = ff_write_chained(oc, stream_index, pkt, s, 0);
> +/* compute new timestamps */
> +offset = av_rescale_q(hls->initial_offset, 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;
> +
> +ret = ff_write_chained(oc, stream_index, pkt, s, hls->initial_offset
> ? 1 : 0);
>
>  return ret;
>  }
> @@ -939,6 +947,7 @@ static const AVOption options[] = {
>  {"event", "EVENT playlist", 0, AV_OPT_TYPE_CONST, {.i64 =
> PLAYLIST_TYPE_EVENT }, INT_MIN, INT_MAX, E, "pl_type" },
>  {"vod", "VOD playlist", 0, AV_OPT_TYPE_CONST, {.i64 =
> PLAYLIST_TYPE_VOD }, INT_MIN, INT_MAX, E, "pl_type" },
>  {"method", "set the HTTP method", OFFSET(method), AV_OPT_TYPE_STRING,
> {.str = NULL},  0, 0,E},
> +{"initial_offset", "set initial timestamp offset",
> OFFSET(initial_offset), AV_OPT_TYPE_DURATION, {.i64 = 0}, -INT64_MAX,
> INT64_MAX, E },
>
>  { NULL },
>  };
> --
> 2.8.1
>
>
LGTM
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avformat/hlsenc: implement initial_offset

2016-09-07 Thread Aman Gupta
From: Aman Gupta 

---
 doc/muxers.texi  |  4 
 libavformat/hlsenc.c | 13 +++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index fd7ee50..e88dbf8 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -389,6 +389,10 @@ to @var{wrap}.
 Start the playlist sequence number from @var{number}. Default value is
 0.
 
+@item initial_offset @var{offset}
+Specify timestamp offset to apply to the output packet timestamps. The
+argument must be a time duration specification, and defaults to 0.
+
 @item hls_allow_cache @var{allowcache}
 Explicitly set whether the client MAY (1) or MUST NOT (0) cache media segments.
 
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 1846d9d..be58db8 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -90,6 +90,7 @@ typedef struct HLSContext {
 uint32_t pl_type;  // enum PlaylistType
 char *segment_filename;
 
+int64_t initial_offset; ///< initial timestamps offset, expressed in 
microseconds
 int use_localtime;  ///< flag to expand filename with localtime
 int use_localtime_mkdir;///< flag to mkdir dirname in timebased filename
 int allowcache;
@@ -795,7 +796,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 HLSContext *hls = s->priv_data;
 AVFormatContext *oc = NULL;
 AVStream *st = s->streams[pkt->stream_index];
-int64_t end_pts = hls->recording_time * hls->number;
+int64_t end_pts = hls->recording_time * hls->number, offset;
 int is_ref_pkt = 1;
 int ret, can_split = 1;
 int stream_index = 0;
@@ -871,7 +872,14 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 return ret;
 }
 
-ret = ff_write_chained(oc, stream_index, pkt, s, 0);
+/* compute new timestamps */
+offset = av_rescale_q(hls->initial_offset, 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;
+
+ret = ff_write_chained(oc, stream_index, pkt, s, hls->initial_offset ? 1 : 
0);
 
 return ret;
 }
@@ -939,6 +947,7 @@ static const AVOption options[] = {
 {"event", "EVENT playlist", 0, AV_OPT_TYPE_CONST, {.i64 = 
PLAYLIST_TYPE_EVENT }, INT_MIN, INT_MAX, E, "pl_type" },
 {"vod", "VOD playlist", 0, AV_OPT_TYPE_CONST, {.i64 = PLAYLIST_TYPE_VOD }, 
INT_MIN, INT_MAX, E, "pl_type" },
 {"method", "set the HTTP method", OFFSET(method), AV_OPT_TYPE_STRING, 
{.str = NULL},  0, 0,E},
+{"initial_offset", "set initial timestamp offset", OFFSET(initial_offset), 
AV_OPT_TYPE_DURATION, {.i64 = 0}, -INT64_MAX, INT64_MAX, E },
 
 { NULL },
 };
-- 
2.8.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel