[FFmpeg-devel] [PATCH] avformat/hlsplaylist: set stream name according to var_stream_map varname

Steven Liu lq at chinaffmpeg.org
Fri Sep 27 15:15:33 EEST 2024



> On Sep 27, 2024, at 19:57, jb <jonbae77 at gmail.com> wrote:
> 
> Sorry for the last empty replay!
> 
> That patch is not working correctly.
> 
> The variable `varname` is also used for multiple video streams.
What about try to use a varname for webvtt, eg. subtitle_varname ?
> 
> Is there another way, to specify the language name?
> 
> Am 26.09.24 um 09:28 schrieb Jonathan Baecker:
>> From: jb-alvarado <jonbae77 at gmail.com>
>> 
>> If name:* is set in var_stream_map variable, take that as NAME= variable. This helps gives better stream names in html players.
>> ---
>>  libavformat/hlsenc.c      | 2 +-
>>  libavformat/hlsplaylist.c | 9 +++++++--
>>  libavformat/hlsplaylist.h | 2 +-
>>  3 files changed, 9 insertions(+), 4 deletions(-)
>> 
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index 1e932b7..8e01721 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -1533,7 +1533,7 @@ static int create_master_playlist(AVFormatContext *s,
>>                  break;
>>              }
>> 
>> -            ff_hls_write_subtitle_rendition(hls->m3u8_out, sgroup, vtt_m3u8_rel_name, vs->language, i, hls->has_default_key ? vs->is_default : 1);
>> +            ff_hls_write_subtitle_rendition(hls->m3u8_out, sgroup, vtt_m3u8_rel_name, vs->language, vs->varname, i, hls->has_default_key ? vs->is_default : 1);
>>          }
>> 
>>          if (!hls->has_default_key || !hls->has_video_m3u8) {
>> diff --git a/libavformat/hlsplaylist.c b/libavformat/hlsplaylist.c
>> index f8a6977..2eedc32 100644
>> --- a/libavformat/hlsplaylist.c
>> +++ b/libavformat/hlsplaylist.c
>> @@ -57,13 +57,18 @@ void ff_hls_write_audio_rendition(AVIOContext *out, const char *agroup,
>> 
>>  void ff_hls_write_subtitle_rendition(AVIOContext *out, const char *sgroup,
>>                                       const char *filename, const char *language,
>> -                                     int name_id, int is_default)
>> +                                     const char *varname, int name_id, int is_default)
>>  {
>>      if (!out || !filename)
>>          return;
>> 
>>      avio_printf(out, "#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID=\"%s\"", sgroup);
>> -    avio_printf(out, ",NAME=\"subtitle_%d\",DEFAULT=%s,", name_id, is_default ? "YES" : "NO");
>> +    if (varname) {
>> +        avio_printf(out, ",NAME=\"%s\",", varname);
>> +    } else {
>> +        avio_printf(out, ",NAME=\"subtitle_%d\",", name_id);
>> +    }
>> +    avio_printf(out, "DEFAULT=%s,", is_default ? "YES" : "NO");
>>      if (language) {
>>          avio_printf(out, "LANGUAGE=\"%s\",", language);
>>      }
>> diff --git a/libavformat/hlsplaylist.h b/libavformat/hlsplaylist.h
>> index d7aa44d..f181182 100644
>> --- a/libavformat/hlsplaylist.h
>> +++ b/libavformat/hlsplaylist.h
>> @@ -41,7 +41,7 @@ void ff_hls_write_audio_rendition(AVIOContext *out, const char *agroup,
>>                                    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);
>> +                                     const char *varname, int name_id, int is_default);
>>  void ff_hls_write_stream_info(AVStream *st, AVIOContext *out, int bandwidth,
>>                                int avg_bandwidth,
>>                                const char *filename, const char *agroup,
>> --
>> 2.46.1
>> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".



More information about the ffmpeg-devel mailing list