From patchwork Wed Jul 3 09:00:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Alfred E. Heggestad" X-Patchwork-Id: 13804 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 B0900448B89 for ; Wed, 3 Jul 2019 12:01:10 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9268E68A4CB; Wed, 3 Jul 2019 12:01:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D5D236805A9 for ; Wed, 3 Jul 2019 12:01:03 +0300 (EEST) Received: by mail-ed1-f53.google.com with SMTP id w13so1302412eds.4 for ; Wed, 03 Jul 2019 02:01:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=ibQmNEjGKQDt0KObHVRAcpOflpbjzXc8qK2gDqxm1uE=; b=CE4+2E7IVRfALhuZ7RnFH9t8ncz3S7uRw6u6AH4hcm2BPwqzFCGS1dvRClcURKtmHz nVWyEo9pHPZS4CrIlaQ+xAiXRSrTat9G/TXE3nowxxlyNU6PSNWN7npXhEmpNS0la4xg XT/tZWS3ryuWNvO1s2VDwPAi/ZxKIa+whXBI1ZibpJ/YOS9M2kTg0pkD2di7ObL4T2Jm 5igOjJ1W9YxGHkVG7xQAbELcuqfynMjCQprfFdmgolrKhv4PqDKfvBcLG1Ocf2pot+Rd Jh72hNvs2rKR/YNL2O2YJsO1H4qlE3XlBIOpnbd/dWsh3A4mDRwCI3S4y7oYbKDKoowx wRxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=ibQmNEjGKQDt0KObHVRAcpOflpbjzXc8qK2gDqxm1uE=; b=iJ+devgUZZxf1rnyvXcKL0GVAu0h9TMjuSTHHzNTV1WqW9EWyLOwhR70f2Rqm7FDyo HZsOgw0OoST0dVq0BF6jkd7CWIgQ4CVIR95eYFca99ynTnHKcKs8HjutOzLvZK3TfML0 9HN1c0czHmV5Lwv2UWV5+O3HafxL8ZGOKeNrC6hwT66bSSncv9KRHNGYJPBphsKWHdT1 +2Y7vMCVvxY4u80ZqN4zw+JOWUzyYfFitZiBtvt/r1GSdgwBuQ7Jv6ZmBuQ1GfTIDRcM uU0tupWEA03Y8dqg4y9m8Jd70rwo3/gpebII5e1FvtSxWwIYF9o79c5fcP+dCYMHGoBJ DZFw== X-Gm-Message-State: APjAAAVQzLAMFS/aPMZA5v7NvRbkjFovd0WxOLnFWxBcOVXXYQjOb1Kc jo10rJflaq9pNt1OasorX2jp1uTw X-Google-Smtp-Source: APXvYqzlsYpla7xZQIMdQJVhmzfQReUYqhiBFGKYFtDQgR1JpSag7Lz2vfoiUiHon30YfwP4PlLvxw== X-Received: by 2002:a50:a544:: with SMTP id z4mr40743142edb.71.1562144463020; Wed, 03 Jul 2019 02:01:03 -0700 (PDT) Received: from Alfreds-MacBook-Pro.local (d126-gw.mnsbone.net. [109.205.9.123]) by smtp.gmail.com with ESMTPSA id j7sm487866eda.97.2019.07.03.02.01.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jul 2019 02:01:02 -0700 (PDT) To: ffmpeg-devel@ffmpeg.org From: "Alfred E. Heggestad" Message-ID: Date: Wed, 3 Jul 2019 11:00:59 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 Content-Language: en-US Subject: [FFmpeg-devel] movenc track_duration 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" Hi, here is my attempt to fix this bug: https://trac.ffmpeg.org/ticket/7966 I am wondering if track_duration should include the last duration or not. I tried to include duration in the calculation of track_duration here: trk->end_pts = pkt->pts; else ... but this adds a warning in the testprogram: (same warning as the ticket) ./libavformat/tests/movenc [mp4 @ 0x7f8ae0801200] track 1: codec frame size is not set write_data len 36, time nopts, type header atom ftyp write_data len 2397, time nopts, type header atom - [mp4 @ 0x7f8ae0801200] Application provided duration: -512 / timestamp: 15360 is out of range for mov/mp4 format [mp4 @ 0x7f8ae0801200] pts has no value write_data len 908, time 1033333, type sync atom moof write_data len 110, time nopts, type trailer atom - 45218facb761a83f686e2363d4f971f4 3451 non-empty-moov [mp4 @ 0x7f8ae0801200] track 1: codec frame size is not set write_data len 36, time nopts, type header atom ftyp write_data len 2729, time nopts, type header atom - [mp4 @ 0x7f8ae0801200] Application provided duration: -512 / timestamp: 14848 is out of range for mov/mp4 format [mp4 @ 0x7f8ae0801200] pts has no value write_data len 1028, time 1000000, type sync atom moof write_data len 110, time nopts, type trailer atom - cf7b45d08c99438d0d55dd2ec28f0fe5 3903 non-empty-moov-elst [mp4 @ 0x7f8ae0801200] track 1: codec frame size is not set write_data len 36, time nopts, type header atom ftyp write_data len 2637, time nopts, type header atom - [mp4 @ 0x7f8ae0801200] Application provided duration: -512 / timestamp: 15360 is out of range for mov/mp4 format [mp4 @ 0x7f8ae0801200] pts has no value write_data len 1028, time 1033333, type sync atom moof write_data len 110, time nopts, type trailer atom - fea7eec4e4d6f0f72a38fe6ea49fac9a 3811 non-empty-moov-no-elst so the bug can be easily provoked with this change. in my humble opinion the check is too strict. /alfred diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 46d314ff17..6cd209266d 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -5612,7 +5612,7 @@ static int mov_write_single_packet(AVFormatContext *s, AVPacket *pkt) // sample in this track. This avoids relying on AVPacket // duration, but only helps for this particular track, not // for the other ones that are flushed at the same time. - trk->track_duration = pkt->dts - trk->start_dts; + trk->track_duration = pkt->dts - trk->start_dts + pkt->duration; if (pkt->pts != AV_NOPTS_VALUE)