Relax error handling when examining FFmpeg files (#2187).
authorCarl Hetherington <cth@carlh.net>
Sat, 12 Feb 2022 23:29:58 +0000 (00:29 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 13 Feb 2022 19:17:56 +0000 (20:17 +0100)
src/lib/ffmpeg_examiner.cc
test/ffmpeg_examiner_test.cc

index 5e53f0974cd61865d8c09287c4b806590ca65d2f..3c6d185f43f0991d3716ad31e12dfb7b5f9dfd20 100644 (file)
@@ -264,12 +264,9 @@ FFmpegExaminer::audio_packet (AVCodecContext* context, shared_ptr<FFmpegAudioStr
        }
 
        int r = avcodec_send_packet (context, packet);
-       if (r < 0 && !(r == AVERROR_EOF && !packet) && r != AVERROR(EAGAIN)) {
-               /* 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.
-                * EAGAIN means we need to do avcodec_receive_frame, so just carry on and do that.
-                */
-               throw DecodeError (N_("avcodec_send_packet"), N_("FFmpegExaminer::audio_packet"), r);
+       if (r < 0) {
+               LOG_WARNING("avcodec_send_packet returned %1 for an audio packet", r);
+               return;
        }
 
        auto frame = audio_frame (stream);
index 655fd1437be76c52f8acf050ebea14de96fe2194..c460830fb09570a31048c808c71c4d7304f1e94e 100644 (file)
@@ -67,3 +67,12 @@ BOOST_AUTO_TEST_CASE (ffmpeg_examiner_probesize_test)
        BOOST_CHECK_EQUAL (examiner->audio_streams()[1]->frame_rate(), 48000);
        BOOST_CHECK_EQUAL (examiner->audio_streams()[1]->channels(), 5);
 }
+
+
+/** Check that a file can be examined without error */
+BOOST_AUTO_TEST_CASE (ffmpeg_examiner_vob_test)
+{
+       auto content = make_shared<FFmpegContent>(TestPaths::private_data() / "bad.vob");
+       auto examiner = make_shared<FFmpegExaminer>(content);
+}
+