mirror of
https://github.com/livepeer/lpms
synced 2026-04-23 00:07:25 +08:00
transcode2() error-tolerant
I was reviewing transcode2() source vs old transcode() and found out that in old code errors in decode loop were "tolerated". What I mean by that is that such error was interrupting the decode loop but the flushing of the filters would still be performed. transcode2() was modified accordingly to replicate previous code's behaviour.
This commit is contained in:
@@ -19,6 +19,13 @@ av_log(NULL, AV_LOG_ERROR, "ERROR: %s:%d] %s : %s\n", __FILE__, __LINE__, msg, e
|
|||||||
return ret; \
|
return ret; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define LPMS_ERR_BREAK(msg) {\
|
||||||
|
char errstr[AV_ERROR_MAX_STRING_SIZE] = {0}; \
|
||||||
|
if (!ret) ret = AVERROR(EINVAL); \
|
||||||
|
if (ret <-1) av_strerror(ret, errstr, sizeof errstr); \
|
||||||
|
av_log(NULL, AV_LOG_ERROR, "ERROR: %s:%d] %s : %s\n", __FILE__, __LINE__, msg, errstr); \
|
||||||
|
break; \
|
||||||
|
}
|
||||||
|
|
||||||
#define LPMS_WARN(msg) {\
|
#define LPMS_WARN(msg) {\
|
||||||
av_log(NULL, AV_LOG_WARNING, "WARNING: %s:%d] %s\n", __FILE__, __LINE__, msg); \
|
av_log(NULL, AV_LOG_WARNING, "WARNING: %s:%d] %s\n", __FILE__, __LINE__, msg); \
|
||||||
|
|||||||
+5
-5
@@ -614,22 +614,22 @@ int transcode2(struct transcode_thread *h,
|
|||||||
break;
|
break;
|
||||||
} else if (ret < 0) {
|
} else if (ret < 0) {
|
||||||
// demuxing error
|
// demuxing error
|
||||||
LPMS_ERR(transcode_cleanup, "Unable to read input");
|
LPMS_ERR_BREAK("Unable to read input");
|
||||||
}
|
}
|
||||||
// all is fine, handle packet just received
|
// all is fine, handle packet just received
|
||||||
ist = ictx->ic->streams[ipkt->stream_index];
|
ist = ictx->ic->streams[ipkt->stream_index];
|
||||||
if (AVMEDIA_TYPE_VIDEO == ist->codecpar->codec_type) {
|
if (AVMEDIA_TYPE_VIDEO == ist->codecpar->codec_type) {
|
||||||
// video packet
|
// video packet
|
||||||
ret = handle_video_packet(h, decoded_results, ipkt, iframe);
|
ret = handle_video_packet(h, decoded_results, ipkt, iframe);
|
||||||
if (ret < 0) goto transcode_cleanup;
|
if (ret < 0) break;
|
||||||
} else if (AVMEDIA_TYPE_AUDIO == ist->codecpar->codec_type) {
|
} else if (AVMEDIA_TYPE_AUDIO == ist->codecpar->codec_type) {
|
||||||
// audio packet
|
// audio packet
|
||||||
ret = handle_audio_packet(h, decoded_results, ipkt, iframe);
|
ret = handle_audio_packet(h, decoded_results, ipkt, iframe);
|
||||||
if (ret < 0) goto transcode_cleanup;
|
if (ret < 0) break;
|
||||||
} else {
|
} else {
|
||||||
// other types of packets (used only for transmuxing)
|
// other types of packets (used only for transmuxing)
|
||||||
handle_other_packet(h, ipkt);
|
handle_other_packet(h, ipkt);
|
||||||
if (ret < 0) goto transcode_cleanup;
|
if (ret < 0) break;
|
||||||
}
|
}
|
||||||
av_packet_unref(ipkt);
|
av_packet_unref(ipkt);
|
||||||
}
|
}
|
||||||
@@ -651,7 +651,7 @@ int transcode2(struct transcode_thread *h,
|
|||||||
// retry
|
// retry
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ret < 0) LPMS_ERR(transcode_cleanup, "Flushing failed");
|
if (ret < 0) LPMS_ERR_BREAK("Flushing failed");
|
||||||
ist = ictx->ic->streams[stream_index];
|
ist = ictx->ic->streams[stream_index];
|
||||||
if (AVMEDIA_TYPE_VIDEO == ist->codecpar->codec_type) {
|
if (AVMEDIA_TYPE_VIDEO == ist->codecpar->codec_type) {
|
||||||
handle_video_frame(h, ist, decoded_results, iframe);
|
handle_video_frame(h, ist, decoded_results, iframe);
|
||||||
|
|||||||
Reference in New Issue
Block a user