Skip to content

Commit 606879e

Browse files
avformat/dashenc: Add CODECS tag to HLS master playlist
1 parent 492b312 commit 606879e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

libavformat/dashenc.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,7 @@ static int write_manifest(AVFormatContext *s, int final)
864864
if (c->hls_playlist && !c->master_playlist_created) {
865865
char filename_hls[1024];
866866
const char *audio_group = "A1";
867+
char audio_codec_str[128] = "\0";
867868
int is_default = 1;
868869
int max_audio_bitrate = 0;
869870

@@ -895,21 +896,31 @@ static int write_manifest(AVFormatContext *s, int final)
895896
playlist_file, i, is_default);
896897
max_audio_bitrate = FFMAX(st->codecpar->bit_rate +
897898
os->muxer_overhead, max_audio_bitrate);
899+
if (!av_strnstr(audio_codec_str, os->codec_str, sizeof(audio_codec_str))) {
900+
if (strlen(audio_codec_str))
901+
av_strlcat(audio_codec_str, ",", sizeof(audio_codec_str));
902+
av_strlcat(audio_codec_str, os->codec_str, sizeof(audio_codec_str));
903+
}
898904
is_default = 0;
899905
}
900906

901907
for (i = 0; i < s->nb_streams; i++) {
902908
char playlist_file[64];
909+
char codec_str[128];
903910
AVStream *st = s->streams[i];
904911
OutputStream *os = &c->streams[i];
905912
char *agroup = NULL;
906913
int stream_bitrate = st->codecpar->bit_rate + os->muxer_overhead;
914+
av_strlcpy(codec_str, os->codec_str, sizeof(codec_str));
907915
if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) && max_audio_bitrate) {
908916
agroup = (char *)audio_group;
909917
stream_bitrate += max_audio_bitrate;
918+
av_strlcat(codec_str, ",", sizeof(codec_str));
919+
av_strlcat(codec_str, audio_codec_str, sizeof(codec_str));
910920
}
911921
get_hls_playlist_name(playlist_file, sizeof(playlist_file), NULL, i);
912-
ff_hls_write_stream_info(st, out, stream_bitrate, playlist_file, agroup, NULL, NULL);
922+
ff_hls_write_stream_info(st, out, stream_bitrate, playlist_file, agroup,
923+
codec_str, NULL);
913924
}
914925
avio_close(out);
915926
if (use_rename)

0 commit comments

Comments
 (0)