[FFmpeg-devel] [PATCH] avformat/hlsenc: Dont write stream info for agroup
Brendan McGrath
redmcg at redmandi.dyndns.org
Thu Jan 18 11:09:47 EET 2018
When using an 'agroup' within var_stream_map - the audio stream is
being added to the master playlist file as both an audio rendition
and an individual stream (with an AUDIO reference back to itself).
This patch ensures an audio rendition does not also appear within
the stream info list.
What follows is an example of the command to create this issue and
the contents of the master playlist before and after this patch is
applied:
ffmpeg -i in.ts -b:a:0 128k -b:v:0 1800k -b:v:1 1024k -map 0:a \
-map 0:v -map 0:v -f hls -var_stream_map "a:0,agroup:audio_0 "\
"v:0,agroup:audio_0 v:1,agroup:audio_0" -master_pl_name \
tv_hls.m3u8 tv_hls_%v.m3u8
Before:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=140800,AUDIO="group_audio_0"
tv_hls_0.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
tv_hls_1.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
tv_hls_2.m3u8
After:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
tv_hls_1.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
tv_hls_2.m3u8
Signed-off-by: Brendan McGrath <redmcg at redmandi.dyndns.org>
---
Pre-patch - the hls stream I was testing would not play on the iOS devices I was testing with.
With the patch applied - they now play the stream
libavformat/hlsenc.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index e36120c..a75853b 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1172,6 +1172,9 @@ static int create_master_playlist(AVFormatContext *s,
for (i = 0; i < hls->nb_varstreams; i++) {
vs = &(hls->var_streams[i]);
+ if (!vs->has_video && !vs->has_subtitle && vs->agroup)
+ continue;
+
m3u8_name_size = strlen(vs->m3u8_name) + 1;
m3u8_rel_name = av_malloc(m3u8_name_size);
if (!m3u8_rel_name) {
--
2.7.4
More information about the ffmpeg-devel
mailing list