From patchwork Sun Jun 10 16:31:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: morten.with@gmail.com X-Patchwork-Id: 9358 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:11c:0:0:0:0:0 with SMTP id c28-v6csp3188859jad; Sun, 10 Jun 2018 09:37:47 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKpbxuMLN6tAAeSo/ydriS+s9sRptIeCAoS0I5YaBLmiAvvNiFf7KyUQjnyr9xQuizXGVdN X-Received: by 2002:adf:a4cf:: with SMTP id h15-v6mr11025054wrb.130.1528648667745; Sun, 10 Jun 2018 09:37:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528648667; cv=none; d=google.com; s=arc-20160816; b=jlA6a0Emk8/zkxYPXp9cQ8fGoxQPGUiQH4yfYamCO7TkgRkvVEnYayBU/+Yfz4dVyV USRgOzeMskNPo9ky3K5C12aY7iWHrkXuEjHattopQ3NM2Ptg0ZtSWCYY8+F/c3AuMn3U hz6BGFtUemX0bhwvwbNSGlAKzvhonXA9hh2eh29v6t0r4TksVI/AZ+z2tA9jvp+eCEHO 2uWqJe4yPq+KMPpzOsrYdyzcw0a/V5n5mQfUAhbsZGMwtC9KkzYkKBKo2kMd6iYiBsuP z/XGRbNNBXdbf9K6ecgn+HbVOHCs7nFHbjhuknWtDWhqfax26qcQS6HgC3h8kHD3ch9w TArQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=BMUFSRILDydjiUPyH/T01++Zsb7G3yvWGbiwWcMtIpM=; b=rLtuYy0l1t3fSIW3LFB68i3sVaBQDFvDGDS659Re8y9GDrexEYok/yhK7EryyOs9JV 2AeZy+ivv1sUbPeofLkweMwwbK9GNjZlrukEkmLtU17nYnvxASxrUlOJQ26vExb7nAON bxBunOzKAHxXhhXWhuib3GtR263k4+y9h3x1R6BFVBjRwTrKuP0PTpRaKDSjMU3DonNb l9gb4bjrjYHoAzdX5EboQI8NioJVkoLkfprHBSRTQgxTvXlDLcJ4TLSsfdmcKInvfGIL jrfSist10AUKgzTRFomdQAi6aj9qxNKrKfcl5NFIn9k7eFndAlQTdSUcG9gSWbwVk3y1 i6ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=Mc9pl9OS; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id v38-v6si39656900wrb.114.2018.06.10.09.37.46; Sun, 10 Jun 2018 09:37:47 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=Mc9pl9OS; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8979968A850; Sun, 10 Jun 2018 19:36:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F3DBE68A7B7 for ; Sun, 10 Jun 2018 19:36:50 +0300 (EEST) Received: by mail-wr0-f194.google.com with SMTP id f16-v6so17920382wrm.3 for ; Sun, 10 Jun 2018 09:37:40 -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=QdWAKz64uGDfzLyIqfhqja9Oy0C4pKNvyH5JpuIBbys=; b=Mc9pl9OSuAIO1I6EQL57iplMicxXXjAXPXtni2DhOHgmdsKN5faVNYZCof2JDnuMhb 6vQmHGUt8buEJ2FEk0PN4QRZEBmtRTYYQFnJiuF7kY5zEdxjh/mAaJjDyKR+bHbuCgfF lhQ8bPV9jGTL+fFqOhFfxcxKbBn14kT2gB85rTgclz+3qhHaIjb88XGcz/JRqdVcKSFu t7yQYuTn6tgP8FZGASmKAiNStSi6YnJJAyHGPoZ7SW2Sl34FIC7VabNNzd8ItuYcHLV1 rHJRWkgGVqBlc3cjch5X2Rik0+XEp6telRCKpluiwS5ifQGjY33XLdkKUyG4jNcHVsEO JUPQ== 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=QdWAKz64uGDfzLyIqfhqja9Oy0C4pKNvyH5JpuIBbys=; b=k/4gXXioYRjvzOQeCrAGmpsn7UhI9tuaulO7796IXtYgbskc5efF1HrnFd36poz7Sx q3qmKxjTOpZPiMbY1IxDiC1nczN/pLUv3o6ELMjiwbbLkHYcQIGMUQqcTdlDvDHQe42F WJfkFuUpaF32CaVNoyGJqkvEltGT3MI6KeN91UBEiwONz6LsOSUbftiKRxDQhGt9UtPP /UJ8SXaGV+Y3gQB0xhHXCpAcEE+efGCV6S04y/e1dhvM5cUMeWe8A02Sb85O1S7imxXY XrZE1X+9IljzexHqJZLpyTRUADU8OQ/xHH1hEMSoCMLQqoLXXlWB20bs0jZe54r9HD4w f/qA== X-Gm-Message-State: APt69E1d/n+IC+E0FAaS6CTS1r3gOpA4Hz1vQI5L3nz9aOnoXOctMo8u rga4g+lanDEvrr8rsanXrlQ1TNwO X-Received: by 2002:adf:ee91:: with SMTP id b17-v6mr11341059wro.21.1528648287985; Sun, 10 Jun 2018 09:31:27 -0700 (PDT) Received: from localhost.localdomain ([84.16.226.17]) by smtp.gmail.com with ESMTPSA id y8-v6sm12280184wrs.0.2018.06.10.09.31.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Jun 2018 09:31:27 -0700 (PDT) From: morten.with@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Sun, 10 Jun 2018 18:31:18 +0200 Message-Id: <20180610163118.5692-1-morten.with@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH] fftools/ffmpeg_opt: Add -toeof option to stop writing relative to EOF 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: withmorten MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: withmorten Signed-off-by: Morten With --- doc/ffmpeg.texi | 4 ++++ fftools/ffmpeg.h | 1 + fftools/ffmpeg_opt.c | 9 +++++++++ 3 files changed, 14 insertions(+) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 3717f22d42..fe635d0e42 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -488,6 +488,10 @@ see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) -to and -t are mutually exclusive and -t has priority. +@item -toeof @var{position} (@emph{input}) +Stop writing the output at @var{position} relative to the "end of file". That is negative +values are later in the file, 0 is at EOF. + @item -fs @var{limit_size} (@emph{output}) Set the file size limit, expressed in bytes. No further chunk of bytes is written after the limit is exceeded. The size of the output file is slightly more than the diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index eb1eaf6363..70026b376e 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -149,6 +149,7 @@ typedef struct OptionsContext { int64_t recording_time; int64_t stop_time; + int64_t stop_time_eof; uint64_t limit_filesize; float mux_preload; float mux_max_delay; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index a2ecddae71..ed28111dc4 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1103,6 +1103,13 @@ static int open_input_file(OptionsContext *o, const char *filename) } } + if (o->stop_time_eof != AV_NOPTS_VALUE) { + if (ic->duration>0) { + o->recording_time = ic->duration + o->stop_time_eof; + } else + av_log(NULL, AV_LOG_WARNING, "Cannot use -toeof, duration of %s not known\n", filename); + } + if (o->start_time_eof != AV_NOPTS_VALUE) { if (ic->duration>0) { o->start_time = o->start_time_eof + ic->duration; @@ -3334,6 +3341,8 @@ const OptionDef options[] = { "duration" }, { "to", HAS_ARG | OPT_TIME | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(stop_time) }, "record or transcode stop time", "time_stop" }, + { "toeof", HAS_ARG | OPT_TIME | OPT_OFFSET | OPT_INPUT, { .off = OFFSET(stop_time_eof) }, + "record or transcode stop time relative to EOF", "time_stop" }, { "fs", HAS_ARG | OPT_INT64 | OPT_OFFSET | OPT_OUTPUT, { .off = OFFSET(limit_filesize) }, "set the limit file size in bytes", "limit_size" }, { "ss", HAS_ARG | OPT_TIME | OPT_OFFSET |