From patchwork Wed Nov 28 17:06:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jeyapal, Karthick" X-Patchwork-Id: 11209 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 AE26B44DDA0 for ; Wed, 28 Nov 2018 19:06:38 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 585AD68A76B; Wed, 28 Nov 2018 19:06:39 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from a2i252.smtp2go.com (a2i252.smtp2go.com [103.47.204.252]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EB90D68A72B for ; Wed, 28 Nov 2018 19:06:32 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpservice.net; s=m78bu0.a1-4.dyn; x=1543425703; h=Feedback-ID: X-Smtpcorp-Track:Message-Id:Date:Subject:To:From:Reply-To:Sender: List-Unsubscribe; bh=paLQw/CEzlYybzULEuIbigPEZk4uEMkUfaQVfxhtu2g=; b=c2uysCOm W8eos87FhsHRKdag6CbXSTnkV/K6fK7rSMAPVrTQq2mLxn2YpXLp7kFDkudVPkhs15omXAK8KHHn6 lyPnwMLLAMqWe7HrIssTBZW32gHGw58FXkPtHfIUrY90r9pUdIVrcXtqt/Ps8zBvnhwjKFkDDAImn UHyK9G0QCMMa00AAX4RTEIqs775nZHYo4HUFu6Fxu1iyclDzbQ6YeX30QYqe1cJhcenll9z511Jl9 9QN5XDOA4DrdBqkWOFfXeWIB7qbvs96fKLdoujvCcQ/ZNaygFwVhy2g/XDOv+AbKoA9zDXTQY9do4 SoBr+4o4dOhclbdmpJ/eIH4DWA==; Received: from [10.45.79.71] (helo=SmtpCorp) by smtpcorp.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.91) (envelope-from ) id 1gS3IL-095AKv-8F; Wed, 28 Nov 2018 17:06:37 +0000 Received: from [10.106.51.17] (helo=blr-mp4tf.bangalore.corp.akamai.com) by smtpcorp.com with esmtpa (Exim 4.91) (envelope-from ) id 1gS3IJ-DuucSq-RJ; Wed, 28 Nov 2018 17:06:36 +0000 From: Karthick J To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Nov 2018 22:36:17 +0530 Message-Id: <20181128170617.97580-2-kjeyapal@akamai.com> X-Mailer: git-send-email 2.17.1 (Apple Git-112) In-Reply-To: <20181128170617.97580-1-kjeyapal@akamai.com> References: <20181128170617.97580-1-kjeyapal@akamai.com> X-Smtpcorp-Track: 1gS3mJDIIcSqRJ.Bosa79Di4 Feedback-ID: 337386m:337386asVRLGB:337386sJXwNlinbF X-Report-Abuse: Please forward a copy of this message, including all headers, to Subject: [FFmpeg-devel] [PATCH v2 2/2] avformat/dashenc: Added an option to ignore io errors 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: Karthick J MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" When dashenc has to run for long duration(say 24x7 live stream), one can enable this option to ignore the io failure of few segment's upload due to an intermittent network issues. When the network connection recovers dashenc will continue with the upload of the current segments, leading to the recovery of the stream. --- doc/muxers.texi | 3 +++ libavformat/dashenc.c | 17 +++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index a02ac01b55..f1cc6f5fee 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -300,6 +300,9 @@ If this flag is set, the dash segment files will be in in ISOBMFF format. @item webm If this flag is set, the dash segment files will be in in WebM format. +@item -ignore_io_errors @var{ignore_io_errors} +Ignore IO errors during open and write. Useful for long-duration runs with network output. + @end table @anchor{framecrc} diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 2f403257c0..04218af6a6 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -138,6 +138,7 @@ typedef struct DASHContext { int index_correction; char *format_options_str; SegmentType segment_type_option; /* segment type as specified in options */ + int ignore_io_errors; } DASHContext; static struct codec_string { @@ -846,7 +847,7 @@ static int write_manifest(AVFormatContext *s, int final) av_dict_free(&opts); if (ret < 0) { av_log(s, AV_LOG_ERROR, "Unable to open %s for writing\n", temp_filename); - return ret; + return c->ignore_io_errors ? 0 : ret; } out = c->mpd_out; avio_printf(out, "\n"); @@ -937,7 +938,7 @@ static int write_manifest(AVFormatContext *s, int final) av_dict_free(&opts); if (ret < 0) { av_log(s, AV_LOG_ERROR, "Unable to open %s for writing\n", temp_filename); - return ret; + return c->ignore_io_errors ? 0 : ret; } ff_hls_write_playlist_version(c->m3u8_out, 7); @@ -1565,8 +1566,9 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt) set_http_options(&opts, c); ret = dashenc_io_open(s, &os->out, os->temp_path, &opts); av_dict_free(&opts); - if (ret < 0) - return ret; + if (ret < 0) { + return c->ignore_io_errors ? 0 : ret; + } } //write out the data immediately in streaming mode @@ -1577,9 +1579,11 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt) write_styp(os->ctx->pb); avio_flush(os->ctx->pb); len = avio_get_dyn_buf (os->ctx->pb, &buf); - avio_write(os->out, buf + os->written_len, len - os->written_len); + if (os->out) { + avio_write(os->out, buf + os->written_len, len - os->written_len); + avio_flush(os->out); + } os->written_len = len; - avio_flush(os->out); } return ret; @@ -1670,6 +1674,7 @@ static const AVOption options[] = { { "auto", "select segment file format based on codec", 0, AV_OPT_TYPE_CONST, {.i64 = SEGMENT_TYPE_AUTO }, 0, UINT_MAX, E, "segment_type"}, { "mp4", "make segment file in ISOBMFF format", 0, AV_OPT_TYPE_CONST, {.i64 = SEGMENT_TYPE_MP4 }, 0, UINT_MAX, E, "segment_type"}, { "webm", "make segment file in WebM format", 0, AV_OPT_TYPE_CONST, {.i64 = SEGMENT_TYPE_WEBM }, 0, UINT_MAX, E, "segment_type"}, + { "ignore_io_errors", "Ignore IO errors during open and write. Useful for long-duration runs with network output", OFFSET(ignore_io_errors), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E }, { NULL }, };