summaryrefslogtreecommitdiff
path: root/libavformat/hlsenc.c
diff options
context:
space:
mode:
authorBela Bodecs <bodecsb@vivanet.hu>2020-01-19 23:01:32 +0100
committerSteven Liu <lq@chinaffmpeg.org>2020-01-20 14:34:30 +0800
commit8c3e9c9cbb725b6fdfe008ded702f3dd8025a58d (patch)
tree02e16312c04d61117b74d1252f897db1673cec3e /libavformat/hlsenc.c
parentdd5c7378bb92f174e7b3b36df3d7685ed60f29c6 (diff)
avformat/hlsenc: fix default AES key file url with variant streams
Currently when hls_enc is active and there are multiple variant stream outputs, default key file url construction does not work, because it is based on the FormatContext' url field. But in case of multiple variant streams, it contains the variant m3u8 output playlist url that contains the %v placeholder. So the result key file url will hold the %v placeholder causing run time error message about "could not write the key file". This patch correct this behaviour, and use the master playlist url for constructing the output key file url when master playlist is vailable. Signed-off-by: Bela Bodecs <bodecsb@vivanet.hu>
Diffstat (limited to 'libavformat/hlsenc.c')
-rw-r--r--libavformat/hlsenc.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 13f34197ed..2b3d3742d9 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -642,13 +642,14 @@ static int do_encrypt(AVFormatContext *s, VariantStream *vs)
int len;
AVIOContext *pb;
uint8_t key[KEYSIZE];
+ char * key_basename_source = (hls->master_m3u8_url) ? hls->master_m3u8_url : s->url;
- len = strlen(s->url) + 4 + 1;
+ len = strlen(key_basename_source) + 4 + 1;
hls->key_basename = av_mallocz(len);
if (!hls->key_basename)
return AVERROR(ENOMEM);
- av_strlcpy(hls->key_basename, s->url, len);
+ av_strlcpy(hls->key_basename, key_basename_source, len);
av_strlcat(hls->key_basename, ".key", len);
if (hls->key_url) {