From patchwork Sun Oct 13 21:14:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 15731 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 A8B804481D6 for ; Mon, 14 Oct 2019 00:14:39 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9290E689E5B; Mon, 14 Oct 2019 00:14:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 62A8D689DD1 for ; Mon, 14 Oct 2019 00:14:33 +0300 (EEST) Received: by mail-pf1-f194.google.com with SMTP id q7so9193593pfh.8 for ; Sun, 13 Oct 2019 14:14:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=tAe5oq2yvMY6lEWRCRYM7Mcltic6farDVGzOlsy9qNw=; b=b3NkV8uQUyEiXFhMRc47ahBTSNyMqBZX/vm59Hgi6zZfObdGwXZUsMUs81mi8eb+aH 5t3FnbgFtfy79nFPT/nBTbjKjjjFQJA3I5AuwNBzS4HYZFRJXDHGtysObFRU30/rtMQ2 5Uf2L/14toYfwfyAHv0BERElRY6FQ5ZDTRekRwKsctGS7Z9Q1zxgoA6q1+yhOoPFv4dB fV6q9zvWzn2eGxka5EP5iNRK3Lih89cPgLyEwGCGM7yw/8Rqj94Q9Oam7Ghn1DlrJMBu x1zM4FirG+fGOvOK1kTxyUSm+vSF5Z5Q46L5vJCs9blK603EuyKroifeFq9zVQrSbFrZ C9ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=tAe5oq2yvMY6lEWRCRYM7Mcltic6farDVGzOlsy9qNw=; b=W11kuei8SeJVZ3LDZDtavhLfoUVEHCnPP+h2FCXMdOizDwGOi9ZiF/iYCWWWZnT8MG A64sxT/kY8kxt1IFKhHI4gQVoBIodVyuelmkgDJDG+LM/1q2D1qpZh9lNDtWw9gbFIfV tspkqZHrMUiVCLq27crq6MUNgBBQmiNgFOgsf7HdzPwRPRVUKn3aoESmbmbnkRfcLw1b blbNrAr7hj+zrp4G7Ia9nr5RoBH0sOC4FaxFNPdlgFUlbZWYCEN/6Cra7oMKA5BQYX58 SNVPPAfGkqCYMzZnxKUe1hm4r5pLD904LgaAqYasmHSV1mvyt7hhLMZGthc/MMXsta5C OHGw== X-Gm-Message-State: APjAAAV1XcXSqD0GvfKwY8OOqDZ80giqav86vOWgyw4QybRLu+UrD8vp 3ZTgIPHCMaS149V0JlCWnftezn90 X-Google-Smtp-Source: APXvYqxsqskFzjar1rSjdWoVtE06q7mxInq3o8C1AldouIDQd/fDz2R4YewuxvyQqzYVHu/gqJwy6Q== X-Received: by 2002:a63:5a59:: with SMTP id k25mr29486630pgm.171.1571001271099; Sun, 13 Oct 2019 14:14:31 -0700 (PDT) Received: from jun-ubuntu.corp.microsoft.com ([2001:4898:80e8:1:fc68:7dc6:2865:2559]) by smtp.googlemail.com with ESMTPSA id p68sm20257138pfp.9.2019.10.13.14.14.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2019 14:14:30 -0700 (PDT) From: Jun Li To: ffmpeg-devel@ffmpeg.org Date: Sun, 13 Oct 2019 14:14:25 -0700 Message-Id: <20191013211425.18923-1-junli1026@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH v2] avformat/tee.c: steal bsf option before passing to fifo muxer 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fix #7620 In the case tee muxer with both "bsf" and "use_fifo" parameters will trigger this bug. Tee muxer will first steal parameters (like "f", "select"...) and then "use_fifo" will try reading out remaining options and pass them to fifo as option "format_options". Current code miss the part of stealing "bsf" options. --- libavformat/tee.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/libavformat/tee.c b/libavformat/tee.c index 89a4ceb280..d91993354b 100644 --- a/libavformat/tee.c +++ b/libavformat/tee.c @@ -159,7 +159,7 @@ static void close_slaves(AVFormatContext *avf) static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave) { int i, ret; - AVDictionary *options = NULL; + AVDictionary *options = NULL, *bsf_options = NULL; AVDictionaryEntry *entry; char *filename; char *format = NULL, *select = NULL, *on_fail = NULL; @@ -186,6 +186,12 @@ static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave) STEAL_OPTION("onfail", on_fail); STEAL_OPTION("use_fifo", use_fifo); STEAL_OPTION("fifo_options", fifo_options_str); + entry = NULL; + while ((entry = av_dict_get(options, "bsfs", entry, AV_DICT_IGNORE_SUFFIX))) { + /* trim out strlen("bsfs") characters from key */ + av_dict_set(&bsf_options, entry->key + 4, entry->value, 0); + av_dict_set(&options, entry->key, NULL, 0); + } ret = parse_slave_failure_policy_option(on_fail, tee_slave); if (ret < 0) { @@ -311,8 +317,8 @@ static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave) } entry = NULL; - while (entry = av_dict_get(options, "bsfs", NULL, AV_DICT_IGNORE_SUFFIX)) { - const char *spec = entry->key + strlen("bsfs"); + while (entry = av_dict_get(bsf_options, "", NULL, AV_DICT_IGNORE_SUFFIX)) { + const char *spec = entry->key; if (*spec) { if (strspn(spec, slave_bsfs_spec_sep) != 1) { av_log(avf, AV_LOG_ERROR, @@ -352,7 +358,7 @@ static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave) } } - av_dict_set(&options, entry->key, NULL, 0); + av_dict_set(&bsf_options, entry->key, NULL, 0); } for (i = 0; i < avf->nb_streams; i++){ @@ -399,6 +405,7 @@ end: av_free(select); av_free(on_fail); av_dict_free(&options); + av_dict_free(&bsf_options); av_freep(&tmp_select); return ret; }