[FFmpeg-devel] [PATCH] libavformat/hls.c: if avio_open2 failed, retry it several times.

2015-11-06 Thread luckliuyuxin
From 6705d9c9e4ded00075b4d8b23cb05ea2c65146ee Mon Sep 17 00:00:00 2001
From: liuyuxin 
Date: Fri, 6 Nov 2015 16:17:40 +0800
Subject: [PATCH] Network environment or video websites maybe lead to
 avio_open2 failed, but if we try avio_open2 several times, it will return
 success.

---
 libavformat/hls.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index ccae270..5d55197 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -41,6 +41,7 @@
 
 #define INITIAL_BUFFER_SIZE 32768
 
+#define MAX_RETRY_COUNT 5
 #define MAX_FIELD_LEN 64
 #define MAX_CHARACTERISTICS_LEN 512
 
@@ -655,8 +656,17 @@ static int parse_playlist(HLSContext *c, const char *url,
 av_dict_set(, "cookies", c->cookies, 0);
 av_dict_set(, "headers", c->headers, 0);
 
-ret = avio_open2(, url, AVIO_FLAG_READ,
- c->interrupt_callback, );
+int try_count = MAX_RETRY_COUNT;
+
+ret = AVERROR_EXIT;
+while (try_count-- && !ff_check_interrupt(c->interrupt_callback)) {
+if ((ret = avio_open2(, url, AVIO_FLAG_READ,
+c->interrupt_callback, )) >= 0) {
+break;
+}
+av_usleep(100*1000);
+}
+
 av_dict_free();
 if (ret < 0)
 return ret;



0001-Network-environment-or-video-websites-maybe-lead-to-.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] libavcodec/parser.c: re-fetch PTS/DTS if fetch failed

2015-04-22 Thread luckliuyuxin
From 00b457adb855b0b25ac7cde4a9cb8c7b53fd0511 Mon Sep 17 00:00:00 2001
From: liuyuxin liuyu...@xiaomi.com
Date: Wed, 22 Apr 2015 16:56:42 +0800
Subject: [PATCH] re-fetch PTS/DTS if fetch failed


Signed-off-by: liuyuxin liuyu...@xiaomi.com
---
 libavcodec/parser.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/parser.c b/libavcodec/parser.c
index b06a959..e62407b 100644
--- a/libavcodec/parser.c
+++ b/libavcodec/parser.c
@@ -163,6 +163,11 @@ int av_parser_parse2(AVCodecParserContext *s, 
AVCodecContext *avctx,
 s-last_dts= s-dts;
 s-last_pos= s-pos;
 ff_fetch_timestamp(s, 0, 0, 0);
+if (s-dts == AV_NOPTS_VALUE  s-pts == AV_NOPTS_VALUE
+ s-pos == -1  !s-offset) {
+//fetch failed, re-fetch next time
+s-fetch_timestamp = 1;
+}
 }
 /* WARNING: the returned index can be negative */
 index = s-parser-parser_parse(s, avctx, (const uint8_t **) poutbuf,

0001-re-fetch-PTS-DTS-if-fetch-failed.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel