From patchwork Sat Aug 25 09:54:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Suciu X-Patchwork-Id: 10128 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:12c4:0:0:0:0:0 with SMTP id 65-v6csp4334235jap; Sat, 25 Aug 2018 03:00:29 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbX5AXYI/4dMju8ICEmJqJ5d2i+8NewGUWAnVTlWHHU1G/9uUhgnWiT6WmsWR0KLy/+G7PH X-Received: by 2002:a1c:7e92:: with SMTP id z140-v6mr799528wmc.48.1535191229494; Sat, 25 Aug 2018 03:00:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535191229; cv=none; d=google.com; s=arc-20160816; b=WXUs5hyXlp37+OJsY+/8EuHqkrVhTkdBYOFw4yR4nK6WFhrhtkhcRUfzEUqDGoUy3u RvyC+UC03/cdmmU31N4ezSOTfptLa7hgmHP98PWksX9Jg+po3YiXQEcr31LufBQ92NoP k5a9psehVuTxI3mwkw7Ym9b+KdXY0eLBb/U0VlL6eMV8MFvLqDFdUfBXHouEJg4mw28d okh6v28+ItzAlFdspLPrqAUNUBt4Vp2SaPrqYiNcVJwv3fmkcr/7i1vnpYAmKS1hayRy YHBjPo+o9yT+a6tchohNpdUpe8DZ/hzBOEMTXCoootqJRB7ZAdWjw0uQ7gNe42smyFuZ ZfrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:in-reply-to:references:mime-version :dkim-signature:delivered-to:arc-authentication-results; bh=NT9FtnIlrUT7ScimDpZdjXSd1Q07rnGkYkv4JUI649k=; b=R3OHzWkgqOo5qNPPdy7hipivsaJHyBNuHCoj18mi3ILiQj2394f9JeTXf68ZWJyde2 VcxuBxKraKnGz6kiK9Yg02GKFE4y7hm2ZzreGfe33RQC6lhCM9/ZlPyUeSQHMpf3lRSU OQL8f8sV/J0LfoNJv/0DbofnqiUl9uXzlVJF21RgWUcTT6V3wJmGqpwje3l4mV5sUzU6 htsk2kQb4k+EWOdek8NCbmcoeIRJdyya9Pe7qqap4hBfnGxAElu+2nojNyUx7ut2TxDz o0LNEVXQ7fK1udJ95KRdKQ3Hq5kdr5WoHoaDB/jEjBPQBMMTGRE4zv3tHuaTYUAF/UqL +t9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=NNdM08sm; 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 l8-v6si7840642wrw.405.2018.08.25.03.00.28; Sat, 25 Aug 2018 03:00:29 -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=NNdM08sm; 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 5CDC7689EA7; Sat, 25 Aug 2018 13:00:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 49FF1689935 for ; Sat, 25 Aug 2018 13:00:17 +0300 (EEST) Received: by mail-lf1-f51.google.com with SMTP id l26-v6so8437094lfc.8 for ; Sat, 25 Aug 2018 03:00:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=PYOhcG/Xbck+OgFWFYv+0Xk5LkZmQWN7QOa5xngOz3k=; b=NNdM08smX458ik+za8aB6ejp9tFuOt/O0wK5RYOulzHzCgWBaSqixL4iXZc2F71U4i st6L7CkJSzj0VYA7w0Z+fl6+4lLKB1x8QsIOkCQOPu0cVAZpIwLVUvm8RpojME0h6Q3M 1KC7A7rRPULSIZq/w4kygZaGog1hOUh4/j5nxzfYic7yATc/XX61x7B9yehUcjouG6YZ 5HwuZDfnM7XJfgxHwlpj6gG2QlpvqgtB9yhN5WnXSD/5V9swOuLBhEn9Bbi0Dm0Bm67E 9yleEzIx2AEP6oYCzc/kfliCYshV+R/EdeTBCpd8x9i51zr43k57xw+ng+KW+UeEUQFf b1YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=PYOhcG/Xbck+OgFWFYv+0Xk5LkZmQWN7QOa5xngOz3k=; b=pSO4ly74fazybT30gQmveS84P2Y3Pw+Sk86v9J6fwL2dpRrt4voRsYynOW8UcTZnKm yVEBV0gn+/jXq7hJQs0LsFBL5aOej5hu6pl/NMKme38xdsJ8r0mw5/T53V9nG7mwE/nl w7PFO8N0mQCvEcE2uhzPzq8C7qRuvDu/dq++F6RIL7W/FxKvBPvR7cZuTucgukcSZEcV 3kGs11P+j8lGuGH8FhuWi/kNspwdLXxLTCFaE5Flm+snVP4kEnDkoNJpJ5HuJktB6DUi AhbvdU2tH5Db7oY8fLggR1myeihpKU9KmNziNgsB+rnjk38q3ABhjXDwAZwepjkonkv8 wMsA== X-Gm-Message-State: APzg51AHmJ5VCViQgBFao8U2FWzOtGSDSiMSFAdt1HvZm1LPitdUgjDM C3+Ml0wpF5tnId6aZ9qWC2eJOfdbdEUCqmfejwWZ1zHG X-Received: by 2002:a19:db55:: with SMTP id s82-v6mr3437718lfg.127.1535190866654; Sat, 25 Aug 2018 02:54:26 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Tudor Suciu Date: Sat, 25 Aug 2018 11:54:19 +0200 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [FFmpeg-devel] make work (live) libsrt 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" Hello, Is this patch in a better shape for inclusion? Regards, On Fri, Aug 24, 2018 at 2:46 AM mypopy@gmail.com wrote: > On Fri, Aug 24, 2018 at 2:55 AM Marton Balint wrote: > > > > > > > > On Thu, 23 Aug 2018, mypopy@gmail.com wrote: > > > > > On Wed, Aug 22, 2018 at 4:30 AM Tudor Suciu > wrote: > > >> > > >> Hello, > > >> > > >> I get errors when I try to send a live srt stream that the first > packet is > > >> too big: > > >> 21:30:39.896626/ffmpeg*E: SRT.c: LiveSmoother: payload size: 1504 > exceeds > > >> maximum allowed 1316 > > >> > > >> Here are example commands for server and client: > > >> ffmpeg -re -i ~/Downloads/ToS-4k-1920.mov -vcodec libx264 -g 50 -refs > 1 -s > > >> 640x360 -b:v 1000k -acodec aac -b:a 64k -flush_packets 0 -f mpegts > "srt:// > > >> 127.0.0.1:5555?mode=listener" > > >> ffplay srt://127.0.0.1:5555 > > >> > > >> A patch that fully solves the issue is: > > >> diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c > > >> index 0f9529d263..156a4776e2 100644 > > >> --- a/libavformat/libsrt.c > > >> +++ b/libavformat/libsrt.c > > >> @@ -412,6 +412,8 @@ static int libsrt_open(URLContext *h, const char > *uri, > > >> int flags) > > >> return AVERROR_UNKNOWN; > > >> } > > >> > > >> + h->max_packet_size = 1316; > > >> + > > >> /* SRT options (srt/srt.h) */ > > >> p = strchr(uri, '?'); > > >> if (p) { > > >> > > >> How would you like this option to be made work in a way that can be > > >> accepted in ffmpeg? > > >> Is there a way to change the max packet size without this patch? > > >> > > > In your case, I don't think hard coding max packet size == 1316 is not > > > a good idea in loopback device, and after deep in the srt > > > library(https://github.com/Haivision/srt) source code, I think srt > > > library need to fix the hardcode about packet size limition. > > > > I can't think of a scenario where limiting the packet size actually > causes > > problems, but if you insist on not limiting it in general, then the max > > packet size should be settable using an option, same way it is for UDP. > > (pkt_size option). I'd suggest using 1316 as default, because that > > is the more common (and currently the only working) use case... > > > > Thanks, > > Marton > I agree with you, giving an option like pkt_size and using 1316 as the > default in this case is a better way to fix this issue. > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > From 5fa19ee0d27eab5181cec57a858f086fecc0615e Mon Sep 17 00:00:00 2001 From: Tudor Suciu Date: Sat, 25 Aug 2018 11:50:07 +0200 Subject: [PATCH] add pkt_length to libsrt --- libavformat/libsrt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c index 0f9529d263..6c147d39e4 100644 --- a/libavformat/libsrt.c +++ b/libavformat/libsrt.c @@ -48,6 +48,7 @@ typedef struct SRTContext { int64_t listen_timeout; int recv_buffer_size; int send_buffer_size; + int pkt_size; int64_t maxbw; int pbkeylen; @@ -73,6 +74,7 @@ static const AVOption libsrt_options[] = { { "listen_timeout", "Connection awaiting timeout", OFFSET(listen_timeout), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, .flags = D|E }, { "send_buffer_size", "Socket send buffer size (in bytes)", OFFSET(send_buffer_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, { "recv_buffer_size", "Socket receive buffer size (in bytes)", OFFSET(recv_buffer_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, + { "pkt_size", "Maximum SRT packet size", OFFSET(pkt_size), AV_OPT_TYPE_INT, { .i64 = 1316 }, -1, INT_MAX, .flags = D|E }, { "maxbw", "Maximum bandwidth (bytes per second) that the connection can use", OFFSET(maxbw), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, .flags = D|E }, { "pbkeylen", "Crypto key len in bytes {16,24,32} Default: 16 (128-bit)", OFFSET(pbkeylen), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 32, .flags = D|E }, { "passphrase", "Crypto PBKDF2 Passphrase size[0,10..64] 0:disable crypto", OFFSET(passphrase), AV_OPT_TYPE_STRING, { .str = NULL }, .flags = D|E }, @@ -412,6 +414,10 @@ static int libsrt_open(URLContext *h, const char *uri, int flags) return AVERROR_UNKNOWN; } + if (flags & AVIO_FLAG_WRITE) { + h->max_packet_size = 1316; + } + /* SRT options (srt/srt.h) */ p = strchr(uri, '?'); if (p) { @@ -442,6 +448,9 @@ static int libsrt_open(URLContext *h, const char *uri, int flags) if (av_find_info_tag(buf, sizeof(buf), "oheadbw", p)) { s->oheadbw = strtoll(buf, NULL, 10); } + if (av_find_info_tag(buf, sizeof(buf), "pkt_size", p)) { + s->pkt_size = strtol(buf, NULL, 10); + } if (av_find_info_tag(buf, sizeof(buf), "tsbpddelay", p)) { s->tsbpddelay = strtol(buf, NULL, 10); } @@ -466,6 +475,9 @@ static int libsrt_open(URLContext *h, const char *uri, int flags) } } } + if (flags & AVIO_FLAG_WRITE && s->pkt_size > 0) { + h->max_packet_size = s->pkt_size; + } return libsrt_setup(h, uri, flags); } -- 2.11.0