Re: [FFmpeg-devel] [PATCH] Add init_program_date_time so start time can be specified

2023-10-17 Thread David Johansen
On Tue, Oct 17, 2023 at 7:09 PM  wrote:

>
>
> On 17 Oct 2023, at 17:51, Dave Johansen wrote:
>
> > ---
> >  doc/muxers.texi  | 3 +++
> >  libavformat/hlsenc.c | 7 ++-
> >  2 files changed, 9 insertions(+), 1 deletion(-)
> >
> > diff --git a/doc/muxers.texi b/doc/muxers.texi
> > index f6071484ff..87c19a5cb9 100644
> > --- a/doc/muxers.texi
> > +++ b/doc/muxers.texi
> > @@ -1086,6 +1086,9 @@ seeking. This flag should be used with the
> @code{hls_time} option.
> >  @item program_date_time
> >  Generate @code{EXT-X-PROGRAM-DATE-TIME} tags.
> >
> > +@item init_program_date_time
> > +Time to start program date time at.
> > +
> >  @item second_level_segment_index
> >  Makes it possible to use segment indexes as %%d in hls_segment_filename
> expression
> >  besides date/time values when strftime is on.
> > diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> > index 4ef84c05c1..474322cc21 100644
> > --- a/libavformat/hlsenc.c
> > +++ b/libavformat/hlsenc.c
> > @@ -28,6 +28,8 @@
> >  #include 
> >  #endif
> >
> > +#include "float.h"
> > +
> >  #include "libavutil/avassert.h"
> >  #include "libavutil/mathematics.h"
> >  #include "libavutil/avstring.h"
> > @@ -212,6 +214,8 @@ typedef struct HLSContext {
> >  int64_t recording_time;
> >  int64_t max_seg_size; // every segment file max size
> >
> > +double init_program_date_time;
> > +
> >  char *baseurl;
> >  char *vtt_format_options_str;
> >  char *subtitle_filename;
> > @@ -2867,7 +2871,7 @@ static int hls_init(AVFormatContext *s)
> >  char *p = NULL;
> >  int http_base_proto = ff_is_http_proto(s->url);
> >  int fmp4_init_filename_len = strlen(hls->fmp4_init_filename) + 1;
> > -double initial_program_date_time = av_gettime() / 100.0;
> > +double initial_program_date_time = hls->init_program_date_time ?
> hls->init_program_date_time : av_gettime() / 100.0;
> >
> >  if (hls->use_localtime) {
> >  pattern = get_default_pattern_localtime_fmt(s);
> > @@ -3141,6 +3145,7 @@ static const AVOption options[] = {
> >  {"split_by_time", "split the hls segment by time which user set by
> hls_time", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_SPLIT_BY_TIME }, 0, UINT_MAX,
>  E, "flags"},
> >  {"append_list", "append the new segments into old hls segment
> list", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_APPEND_LIST }, 0, UINT_MAX,   E,
> "flags"},
> >  {"program_date_time", "add EXT-X-PROGRAM-DATE-TIME", 0,
> AV_OPT_TYPE_CONST, {.i64 = HLS_PROGRAM_DATE_TIME }, 0, UINT_MAX,   E,
> "flags"},
> > +{"init_program_date_time", "Time to start program date time at",
> OFFSET(init_program_date_time), AV_OPT_TYPE_DOUBLE, {.dbl = 0 }, 0,
> DBL_MAX,   E},
>
> This should probably not be mixed into the flags options list.
>
> It seems odd to have the user provide a double here instead of a ISO 8601
> datetime, which is what the spec requires / ends up in the playlist.
> If you do not want to handle the datetime string parsing, at least it
> would be good to give a hint what exactly the double value is expected to
> be here.
>
> However usability-wise I would prefer to accept a proper date/time here…
>

Is there an example of how to accept a string as the option and then do the
parsing that I could base the code on?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] Add init_program_date_time so start time can be specified

2023-10-26 Thread David Johansen
On Thu, Oct 26, 2023 at 7:12 PM Dave Johansen 
wrote:

> ---
>  doc/muxers.texi  |  3 +++
>  libavformat/hlsenc.c | 41 +
>  2 files changed, 28 insertions(+), 16 deletions(-)
>

I submitted a revised set of patches with additional features with this as
the first
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Add CHANNELS to EXT-X-MEDIA for Audio

2023-10-26 Thread David Johansen
>
> LGTM
>
>
> Thanks
> Steven
>

I'm new to ffmpeg development so what's the process for this to be merged?
Do I need to do something or is it taken care of by a different
process/someone else?

Thanks,
Dave
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Add CHANNELS to EXT-X-MEDIA for Audio

2023-10-27 Thread David Johansen
On Fri, Oct 27, 2023 at 1:33 AM Steven Liu  wrote:

> David Johansen  于2023年10月27日周五 12:03写道:
> >
> > >
> > > LGTM
> > >
> > >
> > > Thanks
> > > Steven
> > >
> >
> > I'm new to ffmpeg development so what's the process for this to be
> merged?
> > Do I need to do something or is it taken care of by a different
> > process/someone else?
>
> Nothing, just leave enough time for more developers review, and will
> push this if no more comments.
> Don't worry David, this is valuable patch, you did a great job.
>

Great! Just wanted to make sure I was doing everything needed to get it
merged in.
Thanks,
Dave
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 1/4] avformat/hlsenc: Add init_program_date_time so start time can be specified

2023-10-27 Thread David Johansen
On Fri, Oct 27, 2023 at 4:58 AM  wrote:

> On 27 Oct 2023, at 5:59, Dave Johansen wrote:
> >  @item second_level_segment_index
> >  Makes it possible to use segment indexes as %%d in hls_segment_filename
> expression
> >  besides date/time values when strftime is on.
> > diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> > index 4ef84c05c1..5dfff6b2b6 100644
> > --- a/libavformat/hlsenc.c
> > +++ b/libavformat/hlsenc.c
> > @@ -212,6 +212,8 @@ typedef struct HLSContext {
> >  int64_t recording_time;
> >  int64_t max_seg_size; // every segment file max size
> >
> > +char *init_program_date_time;
> > +
> >  char *baseurl;
> >  char *vtt_format_options_str;
> >  char *subtitle_filename;
> > @@ -1192,6 +1194,25 @@ static int hls_append_segment(struct
> AVFormatContext *s, HLSContext *hls,
> >  return 0;
> >  }
> >
> > +static double parse_iso8601(const char *ptr) {
> > +struct tm program_date_time;
> > +int y,M,d,h,m,s;
> > +double ms;
> > +if (sscanf(ptr, "%d-%d-%dT%d:%d:%d.%lf", &y, &M, &d, &h, &m, &s,
> &ms) != 7) {
> > +return -1;
> > +}
> > +
> > +program_date_time.tm_year = y - 1900;
> > +program_date_time.tm_mon = M - 1;
> > +program_date_time.tm_mday = d;
> > +program_date_time.tm_hour = h;
> > +program_date_time.tm_min = m;
> > +program_date_time.tm_sec = s;
> > +program_date_time.tm_isdst = -1;
> > +
> > +return mktime(&program_date_time) + (double)(ms / 1000);
> > +}
> > +
> >  static int parse_playlist(AVFormatContext *s, const char *url,
> VariantStream *vs)
> >  {
> >  HLSContext *hls = s->priv_data;
> > @@ -1257,24 +1278,11 @@ static int parse_playlist(AVFormatContext *s,
> const char *url, VariantStream *vs
> >  }
> >  }
> >  } else if (av_strstart(line, "#EXT-X-PROGRAM-DATE-TIME:",
> &ptr)) {
> > -struct tm program_date_time;
> > -int y,M,d,h,m,s;
> > -double ms;
> > -if (sscanf(ptr, "%d-%d-%dT%d:%d:%d.%lf", &y, &M, &d, &h,
> &m, &s, &ms) != 7) {
> > +discont_program_date_time = parse_iso8601(ptr);
> > +if (discont_program_date_time < 0) {
> >  ret = AVERROR_INVALIDDATA;
> >  goto fail;
> >  }
> > -
> > -program_date_time.tm_year = y - 1900;
> > -program_date_time.tm_mon = M - 1;
> > -program_date_time.tm_mday = d;
> > -program_date_time.tm_hour = h;
> > -program_date_time.tm_min = m;
> > -program_date_time.tm_sec = s;
> > -program_date_time.tm_isdst = -1;
> > -
> > -discont_program_date_time = mktime(&program_date_time);
> > -discont_program_date_time += (double)(ms / 1000);
> >  } else if (av_strstart(line, "#", NULL)) {
> >  continue;
> >  } else if (line[0]) {
> > @@ -2867,7 +2875,7 @@ static int hls_init(AVFormatContext *s)
> >  char *p = NULL;
> >  int http_base_proto = ff_is_http_proto(s->url);
> >  int fmp4_init_filename_len = strlen(hls->fmp4_init_filename) + 1;
> > -double initial_program_date_time = av_gettime() / 100.0;
> > +double initial_program_date_time = hls->init_program_date_time ?
> parse_iso8601(hls->init_program_date_time) : av_gettime() / 100.0;
>
> As parse_iso8601 parsing user input can fail, it should properly report
> the error and fail. Especially given that it does not accept all variations
> of ISO-8601 date/time IIUC.
>
> It might be confusing if the user specifies a time, forgets the
> milliseconds and it will just silently not use the option at all?
>

I added improved parsing and error reporting. I sent in the patch, but is
there a way for me to tie it to this patchset in the future?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] Separate stream for subtitles in HLS?

2023-11-01 Thread David Johansen
Currently, I have to put the subtitles on the video stream and when I make
the subtitles their own stream, I get this error:
No streams to mux were specified

Would it be possible to have the subtitles as their own stream or is too
engrained of an assumption that there's an output stream tied to each of
the streams? (this appears to be from the call to avformat_init_output)

Thanks,
Dave
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 1/4] avformat/hlsenc: Add init_program_date_time so start time can be specified

2023-11-08 Thread David Johansen
On Sun, Nov 5, 2023 at 1:21 AM Marton Balint  wrote:

>
>
> On Fri, 27 Oct 2023, David Johansen wrote:
>
> > On Fri, Oct 27, 2023 at 4:58 AM  wrote:
> >
> >> On 27 Oct 2023, at 5:59, Dave Johansen wrote:
> >> >  @item second_level_segment_index
> >> >  Makes it possible to use segment indexes as %%d in
> hls_segment_filename
> >> expression
> >> >  besides date/time values when strftime is on.
> >> > diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> >> > index 4ef84c05c1..5dfff6b2b6 100644
> >> > --- a/libavformat/hlsenc.c
> >> > +++ b/libavformat/hlsenc.c
> >> > @@ -212,6 +212,8 @@ typedef struct HLSContext {
> >> >  int64_t recording_time;
> >> >  int64_t max_seg_size; // every segment file max size
> >> >
> >> > +char *init_program_date_time;
> >> > +
> >> >  char *baseurl;
> >> >  char *vtt_format_options_str;
> >> >  char *subtitle_filename;
> >> > @@ -1192,6 +1194,25 @@ static int hls_append_segment(struct
> >> AVFormatContext *s, HLSContext *hls,
> >> >  return 0;
> >> >  }
> >> >
> >> > +static double parse_iso8601(const char *ptr) {
>
> Please use the existing function av_parse_time(). That can more completely
> handle ISO8601 and even more.
>

I made a patch for this an submitted it with --in-reply-to with the Message
ID from this email, but it doesn't appear that it linked it to the existing
patches I sent. What's the proper way that I should submit follow on
patches like this in the future?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Add CHANNELS to EXT-X-MEDIA for Audio

2023-11-08 Thread David Johansen
On Fri, Oct 27, 2023 at 1:33 AM Steven Liu  wrote:

> David Johansen  于2023年10月27日周五 12:03写道:
> >
> > >
> > > LGTM
> > >
> > >
> > > Thanks
> > > Steven
> > >
> >
> > I'm new to ffmpeg development so what's the process for this to be
> merged?
> > Do I need to do something or is it taken care of by a different
> > process/someone else?
>
> Nothing, just leave enough time for more developers review, and will
> push this if no more comments.
> Don't worry David, this is valuable patch, you did a great job.
>

I submitted a handful of patches and I believe I've addressed all of
the feedback I've seen, so is there anything I need to do to follow up on
them and get them merged?

Thanks,
Dave
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] libavformat/hlsenc.c: Populate OTI using AAC profile in write_codec_attr.

2023-12-28 Thread David Johansen
On Fri, Dec 22, 2023 at 8:10 AM Romain Beauxis  wrote:

> This patch populates the third entry for HLS codec attribute using the
> AAC profile.
>
> The HLS specifications[1] require this digit to be the Object Type ID as
> referred to in table 1.3 of ISO/IEC 14496-3:2009[2].
>
> The numerical constants in the code refer to these OTIs minus one, as
> documeted in commit 372597e[3], confirmed by comparing the values in the
> code with the values in the table mentioned above.
>
> Links:
> 1: https://datatracker.ietf.org/doc/html/rfc6381#section-3.3
> 2: https://csclub.uwaterloo.ca/~ehashman/ISO14496-3-2009.pdf
> 3:
> https://github.com/FFmpeg/FFmpeg/commit/372597e5381c097455a7b73849254d56083eb056
>
> ---
>  libavformat/hlsenc.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 7049956dd7..2551bac6ae 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -418,8 +418,10 @@ static void write_codec_attr(AVStream *st,
> VariantStream *vs)
>  } else if (st->codecpar->codec_id == AV_CODEC_ID_MP3) {
>  snprintf(attr, sizeof(attr), "mp4a.40.34");
>  } else if (st->codecpar->codec_id == AV_CODEC_ID_AAC) {
> -/* TODO : For HE-AAC, HE-AACv2, the last digit needs to be set to
> 5 and 29 respectively */
> -snprintf(attr, sizeof(attr), "mp4a.40.2");
> +if (st->codecpar->profile != AV_PROFILE_UNKNOWN)
> +snprintf(attr, sizeof(attr), "mp4a.40.%d",
> st->codecpar->profile+1);
> +else
> +goto fail;
>  } else if (st->codecpar->codec_id == AV_CODEC_ID_AC3) {
>  snprintf(attr, sizeof(attr), "ac-3");
>  } else if (st->codecpar->codec_id == AV_CODEC_ID_EAC3) {
> --
> 2.39.3 (Apple Git-145)
>

I love this change, but it appears that st->codecpar->profile is always
AV_PROFILE_UNKNOWN when using libfdk_aac as the encoder. Any indications
where I should look for fix that so this can be used with that encoder?

Thanks,
Dave
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Add CHANNELS to EXT-X-MEDIA for Audio

2023-12-28 Thread David Johansen
On Wed, Nov 8, 2023 at 6:38 PM Steven Liu  wrote:

> David Johansen  于2023年11月9日周四 07:47写道:
> >
> > On Fri, Oct 27, 2023 at 1:33 AM Steven Liu 
> wrote:
> >
> > > David Johansen  于2023年10月27日周五 12:03写道:
> > > >
> > > > >
> > > > > LGTM
> > > > >
> > > > >
> > > > > Thanks
> > > > > Steven
> > > > >
> > > >
> > > > I'm new to ffmpeg development so what's the process for this to be
> > > merged?
> > > > Do I need to do something or is it taken care of by a different
> > > > process/someone else?
> > >
> > > Nothing, just leave enough time for more developers review, and will
> > > push this if no more comments.
> > > Don't worry David, this is valuable patch, you did a great job.
> > >
> >
> > I submitted a handful of patches and I believe I've addressed all of
> > the feedback I've seen, so is there anything I need to do to follow up on
> > them and get them merged?
> Will apply this patch after 24 hours if there have no more comments.
>

Thanks for applying this patch. I submitted a handful of other patches for
HLS so can those be merged as well?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] libavformat/hlsenc.c: Populate OTI using AAC profile in write_codec_attr.

2023-12-28 Thread David Johansen
>
> I love this change, but it appears that st->codecpar->profile is always
> AV_PROFILE_UNKNOWN when using libfdk_aac as the encoder. Any indications
> where I should look for fix that so this can be used with that encoder?
>

It appears that the issue is that profile doesn't default to what's being
used so `--profile:a` has to be set explicitly with libfdk_aac and then it
works. Not sure if that's an issue worth fixing, but if someone points me
to where it needs to be done, then I'd be glad to take a look at fixing it
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] libavformat/hlsenc.c: Populate OTI using AAC profile in write_codec_attr.

2023-12-30 Thread David Johansen
On Sat, Dec 30, 2023 at 8:23 AM Romain Beauxis  wrote:

> Le jeu. 28 déc. 2023 à 17:26, David Johansen  a
> écrit :
> >>
> >> I love this change, but it appears that st->codecpar->profile is always
> AV_PROFILE_UNKNOWN when using libfdk_aac as the encoder. Any indications
> where I should look for fix that so this can be used with that encoder?
> >
> >
> > It appears that the issue is that profile doesn't default to what's
> being used so `--profile:a` has to be set explicitly with libfdk_aac and
> then it works. Not sure if that's an issue worth fixing, but if someone
> points me to where it needs to be done, then I'd be glad to take a look at
> fixing it
>
> This feels like a second, separate issue to me?
>
> Maybe we could get these changes in first and then tackle it?
>

But this is technically a breaking change, because it takes commands/uses
that currently work and changes them to no longer include CODECS since the
profile value is unknown by default
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".