[FFmpeg-devel] [PATCH 2/2] avformat/hlsenc: support single file mode encryption

Steven Liu lq at chinaffmpeg.org
Fri Jul 10 15:19:37 EEST 2020


fix ticket: 8783

Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
---
 libavformat/hlsenc.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 1d816a61e6..cce6b2faa5 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1722,6 +1722,15 @@ static int hls_start(AVFormatContext *s, VariantStream *vs)
             av_opt_set(oc->priv_data, "mpegts_flags", "resend_headers", 0);
         }
         if (c->flags & HLS_SINGLE_FILE) {
+            if (c->key_info_file || c->encrypt) {
+                av_dict_set(&options, "encryption_key", vs->key_string, 0);
+                av_dict_set(&options, "encryption_iv", vs->iv_string, 0);
+                vs->basename = av_asprintf("crypto:%s", oc->url);
+                if (!vs->basename) {
+                    err = AVERROR(ENOMEM);
+                    goto fail;
+                }
+            }
             set_http_options(s, &options, c);
             if ((err = hlsenc_io_open(s, &vs->out, vs->basename, &options)) < 0) {
                 if (c->ignore_io_errors)
-- 
2.25.0





More information about the ffmpeg-devel mailing list