From patchwork Mon Apr 20 17:57:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wheatley X-Patchwork-Id: 19108 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 2584F44A819 for ; Mon, 20 Apr 2020 20:58:32 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 07AFF68B781; Mon, 20 Apr 2020 20:58:32 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EE50A68B76C for ; Mon, 20 Apr 2020 20:58:25 +0300 (EEST) Received: by mail-wm1-f48.google.com with SMTP id v8so602901wma.0 for ; Mon, 20 Apr 2020 10:58:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=bvGwljeAk7v+GlmFQytIEQxL4oQDzJKYoGadqYe4SRc=; b=SjHMxTsv1WVcSn7rIVVHYfz/v6buzhz6F34S5JyzoMmvfSDY1SOKSeseXLPjTYOGfw EZRYHRlwYUYcG9gzHR+Ky0h3J+2UQvrUXk8m2y3erjXWakhqiYC0gd9gCagpxMRZiDQ/ IyYB8fmatLjkw4YgdQA2BX1B2Ay/vV5Pq0PyhioNt7Y1u3rQgJygvH2FtDCSywpqT82N iYtW9gkLRoQ4YOExyjFrd9bGQdc0AzUIkhChk4np6Rqz1PG9sIwpp9SU17DsCQ0G9yZt nTQ3lVhl01SG8ktkcEA4d5ux1LiNK9Vvl2+PevOsUXHHTzSv4DeYNux1AC5xkveOy3jo /a+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=bvGwljeAk7v+GlmFQytIEQxL4oQDzJKYoGadqYe4SRc=; b=lSVs+gwhUj2Lvf0I5jtjxF65jhe7zMFs5WzAyfv3lv0wUWGhEABHPUJmlExxulGqSi UjGFgdPGjuTyT3uhB0nmAJ4gzyvxzGmWnYMJSxsZUNhEuKkTN/FkoevqCcS1srpI/9He e3JbmcuoLDJBP657WVAVxSthQxKV7BtJp4E9BGWBPdaES1mY/xXMZXiKzH5ew6n5IH5W lh6bXTez/eJdxd+umztJoQJDBgpTPmu9ipqEUsbkH+kV0eHmQWDY0LdjIfHKH6p5eKbN cyJlcwLjM7BejPqlBN853x1JmnbqgcbM/tHKuEh1mJy+5+xuiw/fJPkz+AlXnotN0kN8 SINg== X-Gm-Message-State: AGi0PuZHxPrMV3zZ9VZqn/JP6ssp8ZbwMDHXiufPRF4q8omoPFrvbHPQ xLp0i5q62OzyqqVntNMDLcofcRO/feY= X-Google-Smtp-Source: APiQypLQHaP2Y4I37LOAYDgXqlFQRka5diIrimZ5KX+Le3Nsgl2/Rtcy1OpUP5q7n7LmUfETQfjvEA== X-Received: by 2002:a1c:3b0a:: with SMTP id i10mr566006wma.26.1587405504871; Mon, 20 Apr 2020 10:58:24 -0700 (PDT) Received: from derwent.ldn.framestore.com (ldndefault.framestore.com. [185.101.14.7]) by smtp.gmail.com with ESMTPSA id l5sm287930wrm.66.2020.04.20.10.58.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Apr 2020 10:58:24 -0700 (PDT) From: Kevin Wheatley To: ffmpeg-devel@ffmpeg.org Date: Mon, 20 Apr 2020 18:57:36 +0100 Message-Id: <1587405459-29001-1-git-send-email-kevin.j.wheatley@gmail.com> X-Mailer: git-send-email 1.8.5.6 Subject: [FFmpeg-devel] [PATCH v3 0/3] avformat/movenc: Support for variable timescale in mov containers 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 Cc: Kevin Wheatley MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" v3 - rebased to current master This set of patches work together to facilitate user specified timescales for the Movie Header Atom 'mvhd', which allows constant sample table durations for all frame rates. Currently there is a fixed timescale of 1000, which is not an even multiple of all the typical video frame/field rates. This means when performing certain duration based operations it is possible to be inaccurate. The default behaviour is left at the current default defined by MOV_TIMESCALE, but can be over ridden by using the -mov_timescale option. Typical values of 600 would work for 24, 25 and 30 FPS, for 23.976 and other fractional rates could use 2997 same as Avid (or 24000 though caution should be used when encoding long durations). An automatic mode has been added if a negative value is passed to the option. This will compute an appropriate time scale starting from the lowest numbered video stream's time scale. Example usage that has better behaviour than the current: # Encode 50 frames at 24FPS and concatenate 5 copies ffmpeg -f lavfi -i smptebars=duration=2.083333:size=1920x1080:rate=24 \ -codec dnxhd -pix_fmt yuv422p -b:v 115M smptebars_dnx_1000.mov cat < concat_1000.txt file smptebars_dnx_1000.mov file smptebars_dnx_1000.mov file smptebars_dnx_1000.mov file smptebars_dnx_1000.mov file smptebars_dnx_1000.mov EOF ffmpeg -f concat -i concat_1000.txt -c copy smpte_concat_1000.mov ffprobe smpte_concat_1000.mov The output of ffprobe will show a frame rate of 23.99 due to the effect of ther sample durations in the stts entries. With the new option of -mov_timescale set to 600: ffmpeg -f lavfi -i smptebars=duration=2.083333:size=1920x1080:rate=24 \ -codec dnxhd -pix_fmt yuv422p -b:v 115M -mov_timescale 600 smptebars_dnx_600.mov cat < concat_600.txt file smptebars_dnx_600.mov file smptebars_dnx_600.mov file smptebars_dnx_600.mov file smptebars_dnx_600.mov file smptebars_dnx_600.mov EOF ffmpeg -f concat -i concat_600.txt -c copy -mov_timescale 600 smpte_concat_600.mov ffprobe smpte_concat_600.mov The durations all line up, the stts table is smaller and no rounding issues occur. Kevin Kevin Wheatley (3): avformat/movenc: Add command line option to set base mov file timescale avformat/movenc: Use base container timescale, instead of hard coded default avformat/movenc: Add an automatic timescale computation libavformat/movenc.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++------ libavformat/movenc.h | 2 ++ 2 files changed, 85 insertions(+), 11 deletions(-)