From patchwork Thu May 31 22:20:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Holljes X-Patchwork-Id: 9208 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:11c:0:0:0:0:0 with SMTP id c28-v6csp163354jad; Thu, 31 May 2018 15:27:44 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKaCbhrG3VFI42yEvM/hEeHnWcALhBMk6VwEJn+Kr7mnUyNsHTgYj0dnakhBfSMEH7yY6oP X-Received: by 2002:a1c:934e:: with SMTP id v75-v6mr1124807wmd.52.1527805664621; Thu, 31 May 2018 15:27:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527805664; cv=none; d=google.com; s=arc-20160816; b=tJWld6yR3RmoaGu9b7eXmx2FdmVu8QW7NGWWeUlR9jOhdDXoduw04veEahPS+tlu+a q828+ADFmclFLaSI6Rv2dAjrUdusE/ukO+eymOHRsWh1nR33M9GBCiF9x2j5Dy4sQ5R/ LqV1yeR3HmHIc5D5/9yqWqzd6pAIRZebpcesb3W6XUIN/fl5hDjsKzIMhsoUWaX2y60f NZoh7PP7H7UI/hjEFS+OS8pA6nJSknyS/cQCRWxYZfFNibKlR22b57szqe03S6pjrm0u +qx73mDyL5IpF/cSuPsIgHRJDL6I2cp+8mpoGiHiG3BvUhQfZpErTxsWmr1L6x428QiP wAXg== 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:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=sTbhW9bvfxvKoR/FvGKQ8CsdiYHkGm/VY6U0QFvk92c=; b=onrm0TLo1NTphHT9auIG7NzN4CexrZTfdWboH7NzGTRyrVWfyNdR+ImtHKdVaByl6r b3RmaRHjRChu6+5GkDCwYLX0yCm/TyaubwSagQ8Cx6AItNvaSRBGcidRb8SVwnX/woe0 kFwB4x46p8gyC7/4zLHInvUPRmJPBh8Z6AphyVGuGNyCDr6TbOlyAIfucC98QPBSTALH Neh8f22JyNNumwgLM4aO8FXg2ZAZhMsBqh79ddBMMzwa0aXFFpF4sc/Iw1BWFLMeTKOm 7bRMwiY0D1Tz1pVEyfDQbBjkl/vSfaKeBGda0GClg/HAslZoIL4gy7eusSR528Z92Nnc HvgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@googlemail.com header.s=20161025 header.b=qtE7CYoY; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z33-v6si12921460wrz.413.2018.05.31.15.27.44; Thu, 31 May 2018 15:27:44 -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=@googlemail.com header.s=20161025 header.b=qtE7CYoY; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E0AC568A553; Fri, 1 Jun 2018 01:25:09 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6822968A536 for ; Fri, 1 Jun 2018 01:25:08 +0300 (EEST) Received: by mail-wm0-f67.google.com with SMTP id o13-v6so80519wmf.4 for ; Thu, 31 May 2018 15:25:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0whorv160J14iaowW/NbvSDhxBrwBp+2ZDe3goiHCHE=; b=qtE7CYoYOMRzFBy47nanih6t7q/ar9BWlV2X/sLE0qFYA2vVCuLaJ5tvZIXv1pBtNC yDaqaBX3JzOejpOEpO95l93xiactJOTr3tNU79V2cctbcnqYPRKmEgAR9F9iMJDQ9+U3 JuaOqssVLYGk5pnVYny6MdLcdeXM7JD5lMJLfM/8paP+2+LQa/h7xwc7geAOfRH/bm7h DizKEo8lkuoJug4ncXpr6dAMXvwGtRACO1hUYdYi5x67Atp9aIQYwWoV99hxV7Igop5z woWBfyuXo2jUEJAUmYVUgvK3qejOqf8F54qKbxaX40FUlJbFl769s7HIfBv182CZGBKl dSPw== 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:in-reply-to :references; bh=0whorv160J14iaowW/NbvSDhxBrwBp+2ZDe3goiHCHE=; b=VyQG3aV7MiNb/fviZO35sP8CynNVU9efnTrrSz6W5AhWTOVIc5bVV0EqE6GKe1PWTM twZDlSuPXWwsGcEfw3Rad0IKfnlwQ5MHYjHDVrSXHfxx2dOh2nnkvgdt+sbBmFZoBLUb ZuBogQsW1rgtahjABHlJjyajt5zL/LD6m6EktxMYYUXCo+BVgLO4Tgv28fBvOXo+aoiy fl0meZ/YYL/ghXHRR2gAnyXlpqmUjQB3GZURgaeYktHZPPLb0azGDSKGwf+d+72M0aT2 aV8J6ptP8Q2RbDK6wExEAUVPLNu+l2DbBwZI+FTJaXLQ8iMSc/niqiEHSTyyHg1rJ60f VRew== X-Gm-Message-State: APt69E1RIE9gWmNej1pG6WTZ/eqOHx07pC8EDedynNzW7JXAsB4v+EBG Nr7nyQj8PMUXZTNqyrhDInhBsQ== X-Received: by 2002:a1c:80e:: with SMTP id 14-v6mr1049686wmi.9.1527805244116; Thu, 31 May 2018 15:20:44 -0700 (PDT) Received: from localhost.localdomain ([46.5.2.0]) by smtp.gmail.com with ESMTPSA id 72-v6sm38288429wrb.22.2018.05.31.15.20.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 May 2018 15:20:43 -0700 (PDT) From: Stephan Holljes To: ffmpeg-devel@ffmpeg.org Date: Fri, 1 Jun 2018 00:20:25 +0200 Message-Id: <20180531222032.30111-2-klaxa1337@googlemail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180531222032.30111-1-klaxa1337@googlemail.com> References: <20180528181859.12182-1-klaxa1337@googlemail.com> <20180531222032.30111-1-klaxa1337@googlemail.com> Subject: [FFmpeg-devel] [PATCH 1/8] ffserver.c: Fix timestamp handling, still creates new clusters for mp4 files, but result is playable 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: Stephan Holljes MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Stephan Holljes --- ffserver.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ffserver.c b/ffserver.c index 39e1c32..44306b1 100644 --- a/ffserver.c +++ b/ffserver.c @@ -79,9 +79,7 @@ void *read_thread(void *arg) struct Segment *seg = NULL; AVPacket pkt; AVStream *in_stream; - AVRational tb; - tb.num = 1; - tb.den = AV_TIME_BASE; + AVRational tb = {1, AV_TIME_BASE}; AVStream *stream; AVCodecParameters *params; enum AVMediaType type; @@ -133,7 +131,7 @@ void *read_thread(void *arg) pkt.pos = -1; // current pts - pts = pkt.pts; //av_rescale_q(pkt.pts, in_stream->time_base, tb); + pts = pkt.pts; // current stream "uptime" now = av_gettime_relative() - start; @@ -200,6 +198,7 @@ void write_segment(struct Client *c) struct Segment *seg; int ret; int pkt_count = 0; + AVRational tb = {1, AV_TIME_BASE}; pthread_mutex_lock(&c->buffer_lock); if (av_fifo_size(c->buffer) > 0) { AVFormatContext *fmt_ctx; @@ -249,8 +248,13 @@ void write_segment(struct Client *c) if (ret < 0) break; - pkt.dts = seg->ts[pkt_count]; - pkt.pts = seg->ts[pkt_count+1]; + pkt.dts = av_rescale_q_rnd(seg->ts[pkt_count], tb, + c->ofmt_ctx->streams[pkt.stream_index]->time_base, + AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX); + pkt.pts = av_rescale_q_rnd(seg->ts[pkt_count+1], tb, + c->ofmt_ctx->streams[pkt.stream_index]->time_base, + AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX); + pkt.pos = -1; pkt_count += 2; ret = av_write_frame(c->ofmt_ctx, &pkt); av_packet_unref(&pkt);