From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 977BA40E0A for ; Fri, 31 Dec 2021 11:36:55 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8EDF568B029; Fri, 31 Dec 2021 13:36:27 +0200 (EET) Received: from out162-62-57-252.mail.qq.com (out162-62-57-252.mail.qq.com [162.62.57.252]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 02C4168AFAA for ; Fri, 31 Dec 2021 13:36:18 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1640950569; bh=U+crNSxTn/L39JrfIcgwcl6mhLIvbvOQLJvmPp0VPxQ=; h=From:To:Cc:Subject:Date; b=YC//MHtn7ldDfSMeFhNZL/rNmpunjvdS8uQUgUiSsuUk0e/pQRe1LKHuIWlO72/Mo YnCDhlXlwp17I4jOzOjUMEjZTChhKlPUvshpV7V1FTJT3ecHSxIjov/4xadrEa798i pPKolhhq2Q3OOMwDZ2LxlbPFyEByDCEj11MxhSjg= Received: from ZHILIZHAO-MB2.tencent.com ([113.108.77.69]) by newxmesmtplogicsvrsza5.qq.com (NewEsmtp) with SMTP id 9089FEB7; Fri, 31 Dec 2021 19:36:08 +0800 X-QQ-mid: xmsmtpt1640950568tm51a3gfk Message-ID: X-QQ-XMAILINFO: MpO6L0LObisWnHIJU+YV+mVDzJzIgNE9BF0W9uxnSlb1lPwWqPGYf/1+IJ1+3P 7NHTTUPUfTckFYq84DpjkqCMY87oMk6gs3cX7VTfsYDN/HN6jGHAS7Sf/7dRYHseyE2bNqw1oVqQ oo/muMJwL7SgDWLCawh9KB76QjjN+1JU7z8tF5mvHkiR4CU3Zim0lGaZTiLoK3mIwtl3UfrA58Nf dPsGuelQC9xZUL7sYfxYYoSilpsj4LwP/GPhLIz5kHkfZhgsOckhVTOV6hbjsIuk3lyfmaJ4kh0v K+JmiTOleiJbjR5TC7i3xj7NczJtku35QY5j82Dm1UvN3n3WsB6C5QKUpSyQkiyYYUwjrYg7IwyY YGLDgBNtnJPdpOg6eaqw0V5D7E1YigU8Nb8nn/9AH2IE/LsNf7PbM/phFJ0rrIvYXa4I820yYs7A 7nKrfTJUQ6OuldUsIzxU6UKW9O333pvVlYOf4dniApV4B0ZAjcEPHIjndiZ834SeH1CIpbGMRt1z 8OUdgL9oT2XqV4uXnWHyhPDSLhD92ijNo9GrJTiV1fZNt1ia3L8uWueXGSJPdrPX1JWeSTTqv7H7 UA9QgqGd2dLm1y81Y3cFqg7Akzfma1rOMzmCwSsvuAzr3lZ4QHglNki16vrpyqk9zeCdv3axjdim Dg/tyhJeCF6q6VU/oDdiB/Eispygr/cqZvmCzZsMwrDdREmegMfHIRmQDtEfLV0adippDK8pyGHa 6usBFguMf2oge8xEXTx5JhO1U5vXy++M2DgrrdeoJD+UrXtdGkJgB52IFuKCuiQOeMMRu+ARblAR rjX63RwSOaToio2hOUmo9x/b4lOYSfc/kWa98v3N1YEpNGJnGlbR+s2Wjs4x9B8yI= From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Fri, 31 Dec 2021 19:36:07 +0800 X-OQ-MSGID: <20211231113610.85358-1-quinkblack@foxmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 1/4] avformat/movenc: fix assert failure in get_cluster_duration() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Cc: Zhao Zhili Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: When editlist is disabled, the workaournd method of shift dts to zero and increase the first sample duration doesn't work if the timestamp is larger than mp4 spec restriction (e.g., sample_delta in stts entry). Further more, it triggers get_cluster_duration() assert failure. This patch will drop large offsets between multiple tracks. --- libavformat/movenc.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 0f912dd012..f5bb785b01 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -5917,7 +5917,18 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) * to signal the difference in starting time without an edit list. * Thus move the timestamp for this first sample to 0, increasing * its duration instead. */ - trk->cluster[trk->entry].dts = trk->start_dts = 0; + if (pkt->dts + pkt->duration <= INT32_MAX) { + trk->cluster[trk->entry].dts = trk->start_dts = 0; + } else { + /* Impossible to write a sample duration >= UINT32_MAX. + * Use INT32_MAX as a tight restriction. + */ + trk->start_dts = pkt->dts; + av_log(s, AV_LOG_WARNING, + "Track %d starts with a nonzero dts %" PRId64 + " which will be shifted to zero\n", + pkt->stream_index, pkt->dts); + } } if (trk->start_dts == AV_NOPTS_VALUE) { trk->start_dts = pkt->dts; -- 2.31.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".