summaryrefslogtreecommitdiff
path: root/src/lib/ffmpeg_decoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-06-03 22:55:44 +0200
committerCarl Hetherington <cth@carlh.net>2021-06-04 22:31:07 +0200
commit9f4cb3b340376d93be39dc97c2e0c631e9cf73c4 (patch)
tree9fae847281fbe1a0c674723f6eb36f19ebcd03d3 /src/lib/ffmpeg_decoder.cc
parenta498b8819ab431ecc2aac058b1aadb9e15d396ac (diff)
Fix errors when seeking FFmpeg for some formats.
The comments discuss this in a bit more depth, but basically we see errors from avcodec_send_packet after seek. ffplay etc. seem basically to ignore all errors from avcodec_send_packet, and I can't find a "proper" fix, so here's a half-way house hack: ignore some errors after seek. Nasty.
Diffstat (limited to 'src/lib/ffmpeg_decoder.cc')
-rw-r--r--src/lib/ffmpeg_decoder.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index c5c41fdac..31fbde773 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -427,6 +427,12 @@ FFmpegDecoder::seek (ContentTime time, bool accurate)
for (auto& i: _next_time) {
i.second = boost::optional<dcpomatic::ContentTime>();
}
+
+ /* We find that we get some errors from av_send_packet after a seek. Perhaps we should ignore
+ * all of them (which seems risky), or perhaps we should have some proper fix. But instead
+ * let's ignore the next 2 errors.
+ */
+ _errors_to_ignore = 2;
}
@@ -513,6 +519,12 @@ FFmpegDecoder::decode_and_process_audio_packet (AVPacket* packet)
/* We could cope with AVERROR(EAGAIN) and re-send the packet but I think it should never happen.
* Likewise I think AVERROR_EOF should not happen.
*/
+ if (_errors_to_ignore > 0) {
+ /* We see errors here after a seek, which is hopefully to be nothing to worry about */
+ --_errors_to_ignore;
+ LOG_GENERAL("Ignoring error %1 avcodec_send_packet after seek; will ignore %2 more", r, _errors_to_ignore);
+ return;
+ }
throw DecodeError (N_("avcodec_send_packet"), N_("FFmpegDecoder::decode_and_process_audio_packet"), r);
}