diff mbox series

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

Message ID 20200710121937.2321-2-lq@chinaffmpeg.org
State New
Headers show
Series [FFmpeg-devel,1/2] avformat/hlsenc: use VariantStream basename when use output single file mode
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Steven Liu July 10, 2020, 12:19 p.m. UTC
fix ticket: 8783

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

Patch

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)