Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Steven Liu <lingjiujianke@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Add CHANNELS to EXT-X-MEDIA for Audio
Date: Fri, 27 Oct 2023 10:53:21 +0800
Message-ID: <CADxeRw=_ngBOUe6waj3b5vfNj=3ZuFyrpdLBtWQq7hAAkkP-JQ@mail.gmail.com> (raw)
In-Reply-To: <20231027014359.20208-1-davejohansen@gmail.com>

Dave Johansen <davejohansen@gmail.com> 于2023年10月27日周五 09:44写道:
>
> ---
>  libavformat/dashenc.c     | 3 ++-
>  libavformat/hlsenc.c      | 8 +++++++-
>  libavformat/hlsplaylist.c | 5 ++++-
>  libavformat/hlsplaylist.h | 2 +-
>  4 files changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 96f4a5fbdf..15f700acbc 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -1284,7 +1284,8 @@ static int write_manifest(AVFormatContext *s, int final)
>                      continue;
>                  get_hls_playlist_name(playlist_file, sizeof(playlist_file), NULL, i);
>                  ff_hls_write_audio_rendition(c->m3u8_out, audio_group,
> -                                             playlist_file, NULL, i, is_default);
> +                                             playlist_file, NULL, i, is_default,
> +                                             s->streams[i]->codecpar->ch_layout.nb_channels);
>                  max_audio_bitrate = FFMAX(st->codecpar->bit_rate +
>                                            os->muxer_overhead, max_audio_bitrate);
>                  if (!av_strnstr(audio_codec_str, os->codec_str, sizeof(audio_codec_str))) {
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 4ef84c05c1..7dfb8d0a9f 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1386,6 +1386,7 @@ static int create_master_playlist(AVFormatContext *s,
>      int is_file_proto = proto && !strcmp(proto, "file");
>      int use_temp_file = is_file_proto && ((hls->flags & HLS_TEMP_FILE) || hls->master_publish_rate);
>      char temp_filename[MAX_URL_SIZE];
> +    int nb_channels;
>
>      input_vs->m3u8_created = 1;
>      if (!hls->master_m3u8_created) {
> @@ -1434,8 +1435,13 @@ static int create_master_playlist(AVFormatContext *s,
>              av_log(s, AV_LOG_ERROR, "Unable to find relative URL\n");
>              goto fail;
>          }
> +        nb_channels = 0;
> +        for (j = 0; j < vs->nb_streams; j++)
> +            if (vs->streams[j]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
> +                if (vs->streams[j]->codecpar->ch_layout.nb_channels > nb_channels)
> +                    nb_channels = vs->streams[j]->codecpar->ch_layout.nb_channels;
>
> -        ff_hls_write_audio_rendition(hls->m3u8_out, vs->agroup, m3u8_rel_name, vs->language, i, hls->has_default_key ? vs->is_default : 1);
> +        ff_hls_write_audio_rendition(hls->m3u8_out, vs->agroup, m3u8_rel_name, vs->language, i, hls->has_default_key ? vs->is_default : 1, nb_channels);
>      }
>
>      /* For variant streams with video add #EXT-X-STREAM-INF tag with attributes*/
> diff --git a/libavformat/hlsplaylist.c b/libavformat/hlsplaylist.c
> index 2bf05f3c7c..4f35d0388f 100644
> --- a/libavformat/hlsplaylist.c
> +++ b/libavformat/hlsplaylist.c
> @@ -39,7 +39,7 @@ void ff_hls_write_playlist_version(AVIOContext *out, int version)
>
>  void ff_hls_write_audio_rendition(AVIOContext *out, const char *agroup,
>                                    const char *filename, const char *language,
> -                                  int name_id, int is_default)
> +                                  int name_id, int is_default, int nb_channels)
>  {
>      if (!out || !agroup || !filename)
>          return;
> @@ -49,6 +49,9 @@ void ff_hls_write_audio_rendition(AVIOContext *out, const char *agroup,
>      if (language) {
>          avio_printf(out, "LANGUAGE=\"%s\",", language);
>      }
> +    if (nb_channels) {
> +        avio_printf(out, "CHANNELS=\"%d\",", nb_channels);
> +    }
>      avio_printf(out, "URI=\"%s\"\n", filename);
>  }
>
> diff --git a/libavformat/hlsplaylist.h b/libavformat/hlsplaylist.h
> index 1928fe787d..c2744c227c 100644
> --- a/libavformat/hlsplaylist.h
> +++ b/libavformat/hlsplaylist.h
> @@ -38,7 +38,7 @@ typedef enum {
>  void ff_hls_write_playlist_version(AVIOContext *out, int version);
>  void ff_hls_write_audio_rendition(AVIOContext *out, const char *agroup,
>                                    const char *filename, const char *language,
> -                                  int name_id, int is_default);
> +                                  int name_id, int is_default, int nb_channels);
>  void ff_hls_write_subtitle_rendition(AVIOContext *out, const char *sgroup,
>                                       const char *filename, const char *language,
>                                       int name_id, int is_default);
> --
> 2.39.2 (Apple Git-143)
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

LGTM


Thanks
Steven
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

  reply	other threads:[~2023-10-27  2:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-27  1:43 Dave Johansen
2023-10-27  2:53 ` Steven Liu [this message]
2023-10-27  4:02   ` David Johansen
2023-10-27  7:32     ` Steven Liu
2023-10-27 20:18       ` David Johansen
2023-11-08 23:47       ` David Johansen
2023-11-09  1:37         ` Steven Liu
2023-12-28 22:49           ` David Johansen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADxeRw=_ngBOUe6waj3b5vfNj=3ZuFyrpdLBtWQq7hAAkkP-JQ@mail.gmail.com' \
    --to=lingjiujianke@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git