diff mbox series

[FFmpeg-devel] avformat/hlsenc: fix default AES key file url with variant streams

Message ID dfd18084-7ca6-4dfa-080d-3a482e1914b2@vivanet.hu
State New
Headers show
Series [FFmpeg-devel] avformat/hlsenc: fix default AES key file url with variant streams
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Bodecs Bela Jan. 19, 2020, 10:10 p.m. UTC
Dear All,

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. (m3u8 playlist output)
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 also 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.

please review this patch!

thank you in advance,

Bela
From 0d299e323bf04ae97c5e20778423537d10b16b4b Mon Sep 17 00:00:00 2001
From: Bela Bodecs <bodecsb@vivanet.hu>
Date: Sun, 19 Jan 2020 23:01:32 +0100
Subject: [PATCH] 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>
---
 libavformat/hlsenc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Steven Liu Jan. 20, 2020, 6:43 a.m. UTC | #1
> 在 2020年1月20日,06:10,Bodecs Bela <bodecsb@vivanet.hu> 写道:
> 
> Dear All,
> 
> 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. (m3u8 playlist output)
> 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 also 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.
> 
> please review this patch!
> 
> thank you in advance,
> 
> Bela
> 
> 
> <0001-avformat-hlsenc-fix-default-AES-key-file-url-with-va.patch>_______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

Applied

Thanks
Steven
diff mbox series

Patch

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index d130f03ea62..dd6343a9fe9 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) {