Ignore errors from avcodec_send_packet.
authorCarl Hetherington <cth@carlh.net>
Wed, 13 Oct 2021 13:50:13 +0000 (15:50 +0200)
committerCarl Hetherington <cth@carlh.net>
Wed, 13 Oct 2021 13:52:40 +0000 (15:52 +0200)
After seeking it appears that we often get irrelevant errors from this
method.  ffplay.c seems to ignore them, and this commit means that
we do too (just logging them).

I think these errors during a non-seeking "encoding" run could be
cause for concern; perhaps we should take more note of them in that
case.

src/lib/ffmpeg_decoder.cc
src/lib/ffmpeg_decoder.h

index 2baa99876b173adbf58e52d4774f80c5a2c393cd..ea961a894d5446b5a81731ea86909a14cc918635 100644 (file)
@@ -423,12 +423,6 @@ 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;
 }
 
 
@@ -512,18 +506,8 @@ FFmpegDecoder::decode_and_process_audio_packet (AVPacket* packet)
 
        int r = avcodec_send_packet (context, packet);
        if (r < 0) {
-               /* 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);
+               LOG_WARNING("avcodec_send_packet returned %1 for an audio packet", r);
        }
-
        while (r >= 0) {
                r = avcodec_receive_frame (context, _frame);
                if (r == AVERROR(EAGAIN)) {
@@ -548,11 +532,8 @@ FFmpegDecoder::decode_and_process_video_packet (AVPacket* packet)
        auto context = video_codec_context();
 
        int r = avcodec_send_packet (context, packet);
-       if (r < 0 && !(r == AVERROR_EOF && !packet)) {
-               /* We could cope with AVERROR(EAGAIN) and re-send the packet but I think it should never happen.
-                * AVERROR_EOF can happen during flush if we've already sent a flush packet.
-                */
-               throw DecodeError (N_("avcodec_send_packet"), N_("FFmpegDecoder::decode_and_process_video_packet"), r);
+       if (r < 0) {
+               LOG_WARNING("avcodec_send_packet returned %1 for a video packet", r);
        }
 
        r = avcodec_receive_frame (context, _frame);
index def824feb042d73f78282bf0466fafe67a86b9e7..fce3fcae92230da92b955000e8ffdfe4b9498c89 100644 (file)
@@ -79,9 +79,6 @@ private:
        /** true if we have a subtitle which has not had emit_stop called for it yet */
        bool _have_current_subtitle = false;
 
-       /** number of errors from avcodec_send_packet to ignore */
-       int _errors_to_ignore = 0;
-
        std::shared_ptr<Image> _black_image;
 
        std::map<std::shared_ptr<FFmpegAudioStream>, boost::optional<dcpomatic::ContentTime>> _next_time;