mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-26 19:01:44 +02:00
avformat/hlsenc: Add CHANNELS to EXT-X-MEDIA for Audio
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
This commit is contained in:
parent
9bcbe04aa0
commit
39878fc504
@ -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))) {
|
||||
|
@ -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*/
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user