From patchwork Tue Feb 18 16:13:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 17833 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 DC00044A270 for ; Tue, 18 Feb 2020 18:21:11 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B2B8F6898D5; Tue, 18 Feb 2020 18:21:11 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 100ED688288 for ; Tue, 18 Feb 2020 18:21:06 +0200 (EET) Received: by mail-qk1-f196.google.com with SMTP id z19so20023708qkj.5 for ; Tue, 18 Feb 2020 08:21:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=Y0LETgYrvRirdvm04u0FB5MzjmYgujD8+Hm8mhmwmoo=; b=MnoVjCrIpKe/DcOChxd8mXiOZ0P+Z5uGY702OvS19+Q5TnFdBLNNbVxUcjfeCVy278 ebyzYDiIDW6kVRELmgJfdqVcLE+WCpgZtlLJpVzeSkOzyYQqVb01tKGK5Nvi6zUzB7CY G6s2EmXFP1GAeAoeq6XL8BMEeNM8fsvqJbmzJs3HSqFMmzu1Mc1p5UgAcOFXaTQCdt28 0sjuBeNue/K+B2zmcKOgemcC3p5Xg7d5feDFWciMGU1fW4tjsQ+pVK1pb2IqK9jiePTO DuVXwAq7eEc1RsqdY5+utCRUDsASnSGtHZbAjAHE27TZ6tZbFytPAX4p/F+hrGap7pvL ogeQ== 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:mime-version :content-transfer-encoding; bh=Y0LETgYrvRirdvm04u0FB5MzjmYgujD8+Hm8mhmwmoo=; b=eOeNcXQ01YxyPUkTRlYsmckr/UvyD9umxkprX51xcszWdevlZ+A/orCwMhRP7FTwqt 6oW885QI+uuoYtQgyrdVVrlyqtm4QmD+liqOiSgj3+e+c0N6gqhGRvFJgOhvewpGIU+y z1UnrdxLtgxgB6EMqZ3Qq22uLkAX/9zYFP2dvnhhOFZ6RhFLH5TnKXalken4qj/VmcZZ nHSRbSM8w+BzKbXUcOaucuQ0D+r8XUUaQOwP4moIvDMu2YWmmDFayX25ONP+ITINHN/F YewizNnk8UzvomGek6oDt6+xgfaABauruEQAo5euo1mlxO0swoyocTuiCq/h76fKF4Kb WJGg== X-Gm-Message-State: APjAAAU+A2oF5VxVn9dnCub99c6dkKGOGsMM7CL9VV8asNvJWVsApCX1 2g952z/XUFWIyG5lYkmWkScJfZdA X-Google-Smtp-Source: APXvYqz5YcvVUwQfAbj0c6+Lp7eD08tHjg56hUWtDNkMgeSpxgPuBRVpZxFQuFtAwUtugZ/BYL1VRw== X-Received: by 2002:a37:a389:: with SMTP id m131mr3748968qke.251.1582042486318; Tue, 18 Feb 2020 08:14:46 -0800 (PST) Received: from localhost.localdomain ([191.83.214.166]) by smtp.gmail.com with ESMTPSA id 123sm745040qkj.113.2020.02.18.08.14.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 08:14:45 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Tue, 18 Feb 2020 13:13:34 -0300 Message-Id: <20200218161336.1804-1-jamrial@gmail.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] avformat/dashenc: write the styp box when the first frame of a segment is ready 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" This ensures it's written at the beginning of a segment in non streaming mode when segment duration differs from fragment duration. Signed-off-by: James Almer --- libavformat/dashenc.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index c89aa3a32c..5c1d24d3e2 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -1911,12 +1911,8 @@ static int dash_flush(AVFormatContext *s, int final, int stream) continue; } - if (!c->single_file) { - if (os->segment_type == SEGMENT_TYPE_MP4 && !os->written_len) - write_styp(os->ctx->pb); - } else { + if (c->single_file) snprintf(os->full_path, sizeof(os->full_path), "%s%s", c->dirname, os->initfile); - } ret = flush_dynbuf(c, os, &range_length); if (ret < 0) @@ -2188,6 +2184,8 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt) AVDictionary *opts = NULL; const char *proto = avio_find_protocol_name(s->url); int use_rename = proto && !strcmp(proto, "file"); + if (os->segment_type == SEGMENT_TYPE_MP4) + write_styp(os->ctx->pb); os->filename[0] = os->full_path[0] = os->temp_path[0] = '\0'; ff_dash_fill_tmpl_params(os->filename, sizeof(os->filename), os->media_seg_name, pkt->stream_index, @@ -2212,8 +2210,6 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt) if (c->streaming && os->segment_type == SEGMENT_TYPE_MP4) { int len = 0; uint8_t *buf = NULL; - if (!os->written_len) - write_styp(os->ctx->pb); avio_flush(os->ctx->pb); len = avio_get_dyn_buf (os->ctx->pb, &buf); if (os->out) {