From patchwork Mon Nov 26 10:25:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jeyapal, Karthick" X-Patchwork-Id: 11164 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 46D0044C5EC for ; Mon, 26 Nov 2018 12:26:26 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C599768A60C; Mon, 26 Nov 2018 12:26:26 +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 7308168A284 for ; Mon, 26 Nov 2018 12:26:20 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpservice.net; s=m78bu0.a1-4.dyn; x=1543228890; h=Feedback-ID: X-Smtpcorp-Track:Message-Id:Date:Subject:To:From:Reply-To:Sender: List-Unsubscribe; bh=DAOhNadDJqlz1CDZUg1GOQ37n29fE0T9YJ58vTeBMbA=; b=fibYIwLK PEFIDZZLPSazGaqh9KbVHRNUbMDyP4aPfzz7eW0t1Z26Txqz0cdf8DZ+Fg8PYUjlR21t0VetwUbC8 pcz5Shs2qv7PpMeKeG4qJ/nfZVKwWnWRKiR1auUYa3VFjAzVfqTB5ogDGz+VYRoYDdKpYQg6w+auP 5fqVsdjRAdS/toNaSRdBw5IG0ehqtnSWasfnCgmeQde7DKgQ+WnpgG4KtW/nZGmcbs5yDqaUBciXT RejkoYXNq/EqQ+L83/dV6VK4jaefDhldT7BUYsSMZNrP3vf1acpH6lUwPecFyusvwDlKZ/3mUq+4Y 5nS8sF/OripHNDu1R47oeXXk6w==; Received: from [10.45.33.53] (helo=SmtpCorp) by smtpcorp.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.91) (envelope-from ) id 1gRE5v-095CuO-5Y; Mon, 26 Nov 2018 10:26:23 +0000 Received: from [10.63.208.195] (helo=blr-mp4tf.bangalore.corp.akamai.com) by smtpcorp.com with esmtpa (Exim 4.91) (envelope-from ) id 1gRE5t-rlZGcs-Pd; Mon, 26 Nov 2018 10:26:22 +0000 From: Karthick J To: ffmpeg-devel@ffmpeg.org Date: Mon, 26 Nov 2018 15:55:51 +0530 Message-Id: <20181126102551.57188-2-kjeyapal@akamai.com> X-Mailer: git-send-email 2.17.1 (Apple Git-112) In-Reply-To: <20181126102551.57188-1-kjeyapal@akamai.com> References: <20181126102551.57188-1-kjeyapal@akamai.com> X-Smtpcorp-Track: 1gRE5tr_ZGcsed.A4puWGVhs Feedback-ID: 337386m:337386asVRLGB:337386sW_RoWgRZ1 X-Report-Abuse: Please forward a copy of this message, including all headers, to Subject: [FFmpeg-devel] [PATCH 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 | 26 ++++++++++++++++++++------ 2 files changed, 23 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..92b09417df 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,10 @@ 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; + if (c->ignore_io_errors) + return 0; + else + return ret; } out = c->mpd_out; avio_printf(out, "\n"); @@ -937,7 +941,10 @@ 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; + if (c->ignore_io_errors) + return 0; + else + return ret; } ff_hls_write_playlist_version(c->m3u8_out, 7); @@ -1565,8 +1572,12 @@ 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) { + if (c->ignore_io_errors) + return 0; + else + return ret; + } } //write out the data immediately in streaming mode @@ -1577,9 +1588,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 +1683,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 }, };