From patchwork Sun Jan 19 22:10:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bodecs Bela X-Patchwork-Id: 17430 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 8D5F044A8E0 for ; Mon, 20 Jan 2020 00:10:50 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 70CB268B017; Mon, 20 Jan 2020 00:10:50 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.vivacom.hu (mail.vivacom.hu [185.92.116.29]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2435C68AE75 for ; Mon, 20 Jan 2020 00:10:44 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by mail.vivacom.hu (Postfix) with ESMTP id B565F89AD1 for ; Sun, 19 Jan 2020 23:10:43 +0100 (CET) X-Virus-Scanned: amavisd-new at example.com Received: from mail.vivacom.hu ([127.0.0.1]) by localhost (mail.vivacom.intra [127.0.0.1]) (amavisd-new, port 10024) with LMTP id ficrK2Euq4us for ; Sun, 19 Jan 2020 23:10:42 +0100 (CET) Received: from [192.168.0.6] (94-21-161-30.pool.digikabel.hu [94.21.161.30]) by mail.vivacom.hu (Postfix) with ESMTPA id E626B89AB9 for ; Sun, 19 Jan 2020 23:10:41 +0100 (CET) To: FFmpeg development discussions and patches From: Bodecs Bela Message-ID: Date: Sun, 19 Jan 2020 23:10:41 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 Content-Language: hu Subject: [FFmpeg-devel] [PATCH] avformat/hlsenc: fix default AES key file url with variant streams X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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 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 --- libavformat/hlsenc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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) {