From patchwork Thu Nov 24 11:02:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Hochecker X-Patchwork-Id: 1550 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.90.1 with SMTP id o1csp351475vsb; Thu, 24 Nov 2016 11:03:14 -0800 (PST) X-Received: by 10.194.122.65 with SMTP id lq1mr3759645wjb.12.1480014194795; Thu, 24 Nov 2016 11:03:14 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id d76si9676364wma.50.2016.11.24.11.03.13; Thu, 24 Nov 2016 11:03:14 -0800 (PST) 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=@kodi-tv.20150623.gappssmtp.com; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7BD9A6899EB; Thu, 24 Nov 2016 21:03:07 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wj0-f196.google.com (mail-wj0-f196.google.com [209.85.210.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A77F568096F for ; Thu, 24 Nov 2016 13:02:54 +0200 (EET) Received: by mail-wj0-f196.google.com with SMTP id kp2so3002821wjc.0 for ; Thu, 24 Nov 2016 03:02:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kodi-tv.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=YQLMdeCSO2FFiXs6qfsopFMJx75fLH2ZTr9XuZKAKfA=; b=LYAggsRpEQWyLuifBbpNGe/QalT0cz0t0Z82Lc/TfDLNefiQt0pfdQbvKNA0S5mrMO HRaB6Js3X8LqnG/gRTA94lhpiPu9BVqcyO6eY60eoFkiDCqqvxVMaucWfW6dTm9dXWhe UmbmUG1jroeygNUsFPt9WhRE6LmeW4a6Fd46EyqnzPTMWutsZs8HCUx1SH8TYUkPlQ9v G0LwSDWTiCmMMFeS5fHlpPyoh4rFZjewKCieY47IZFMxklGhNbkkYY3AbtI90EBoKiKS a/6TJgIE8P+c6hIZoJQ/28nN6VrDHf94sgIS3jnE7/9pTmycM6DLkeHtoFyaNS3kjO8G oBrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=YQLMdeCSO2FFiXs6qfsopFMJx75fLH2ZTr9XuZKAKfA=; b=eBqYSyNgd7BxtaaIlovJIEKzHBIZAmRUXnnmu2h6tTInAAdEl5Rnhc/ctcJvBAB/6s dNjtdICtEH8+uxcQNm3CO/P5i1Xrrkfaihf2ZvW0AnXLovfVnX+bNrN8rWkxeY85ClXU UXKOWunSaKXZM+V+SYVjcRVIcEs5+yGhZnAMveu0nv41lNXHHv8znEH/QW7jsZZlg7Pl WDozXO5urPszmkXKsVmUjoIcY+9IKH5b/364ffQuk384jgAyCN8HUscCFiaIXZcMQzLu wfQh6Jw+Bnoa23UZc9hKM7XPcqsWPw+C/CIZQ21b/5tMgTzeSBeEWMMJiHA6z8SCwvh1 oRKQ== X-Gm-Message-State: AKaTC02wPZm60lww2TNVnTxaI8GvqwKSysNyChJ7kF/paU6TX9boeEASMTtjMdyUan1y4Opm X-Received: by 10.194.201.133 with SMTP id ka5mr1833393wjc.151.1479985378158; Thu, 24 Nov 2016 03:02:58 -0800 (PST) Received: from ID99.fritz.box (p2003006325523900DE9C52FFFE00000C.dip0.t-ipconnect.de. [2003:63:2552:3900:de9c:52ff:fe00:c]) by smtp.gmail.com with ESMTPSA id ia7sm41138682wjb.23.2016.11.24.03.02.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Nov 2016 03:02:57 -0800 (PST) From: Rainer Hochecker To: ffmpeg-devel@ffmpeg.org Date: Thu, 24 Nov 2016 12:02:45 +0100 Message-Id: <20161124110245.3855-1-fernetmenta@kodi.tv> X-Mailer: git-send-email 2.9.3 X-Mailman-Approved-At: Thu, 24 Nov 2016 21:03:06 +0200 Subject: [FFmpeg-devel] [PATCH] matroska read_seek: make max diff for last known subtitle configurable 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: Rainer Hochecker MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Rainer Hochecker Allow players to reduce the time read_seek sets the file pos before desired position. Hard coded 30 seconds is a lot and takes several seconds when the source is on a network share. Signed-off-by: Rainer Hochecker --- libavformat/matroskadec.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index f79511e..eb2bc31 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -353,6 +353,9 @@ typedef struct MatroskaDemuxContext { /* WebM DASH Manifest live flag/ */ int is_live; + + /* set file pos up to 30 seconds before desired timestamp on seek */ + int subtitle_seek_diff; } MatroskaDemuxContext; typedef struct MatroskaBlock { @@ -3407,7 +3410,7 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index, while (index_sub >= 0 && index_min > 0 && tracks[i].stream->index_entries[index_sub].pos < st->index_entries[index_min].pos && - st->index_entries[index].timestamp - tracks[i].stream->index_entries[index_sub].timestamp < 30000000000 / matroska->time_scale) + st->index_entries[index].timestamp - tracks[i].stream->index_entries[index_sub].timestamp < matroska->subtitle_seek_diff * 1E9 / matroska->time_scale) index_min--; } } @@ -3813,9 +3816,17 @@ static int webm_dash_manifest_read_packet(AVFormatContext *s, AVPacket *pkt) #define OFFSET(x) offsetof(MatroskaDemuxContext, x) static const AVOption options[] = { { "live", "flag indicating that the input is a live file that only has the headers.", OFFSET(is_live), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, + { "subtitle_seek_diff", "max difference in seconds between desired seek pos and last known subtitle pos.", OFFSET(subtitle_seek_diff), AV_OPT_TYPE_INT, {.i64 = 30}, 0, 30, AV_OPT_FLAG_DECODING_PARAM }, { NULL }, }; +static const AVClass matroska_class = { + .class_name = "matroska,webm demuxer", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + static const AVClass webm_dash_class = { .class_name = "WebM DASH Manifest demuxer", .item_name = av_default_item_name, @@ -3828,6 +3839,7 @@ AVInputFormat ff_matroska_demuxer = { .long_name = NULL_IF_CONFIG_SMALL("Matroska / WebM"), .extensions = "mkv,mk3d,mka,mks", .priv_data_size = sizeof(MatroskaDemuxContext), + .priv_class = &matroska_class, .read_probe = matroska_probe, .read_header = matroska_read_header, .read_packet = matroska_read_packet,