From 9cc13afa143cd847d365cfbc8b5531e1f8cbb59e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 1 Nov 2012 12:56:53 +0000 Subject: [PATCH] Log on av_read_frame error (rather than aborting) and log on unused data in a packet. --- src/lib/ffmpeg_decoder.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 60f5bf7f5..09f699543 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -224,7 +224,10 @@ FFmpegDecoder::do_pass () if (r < 0) { if (r != AVERROR_EOF) { - throw DecodeError ("error on av_read_frame"); + /* Maybe we should fail here, but for now we'll just finish off instead */ + char buf[256]; + av_strerror (r, buf, sizeof(buf)); + _film->log()->log (String::compose ("error on av_read_frame (%1) (%2)", buf, r)); } /* Get any remaining frames */ @@ -259,7 +262,12 @@ FFmpegDecoder::do_pass () if (_packet.stream_index == _video_stream) { int frame_finished; - if (avcodec_decode_video2 (_video_codec_context, _frame, &frame_finished, &_packet) >= 0 && frame_finished) { + int const r = avcodec_decode_video2 (_video_codec_context, _frame, &frame_finished, &_packet); + if (r >= 0 && frame_finished) { + + if (r != _packet.size) { + _film->log()->log (String::compose ("Used only %1 bytes of %2 in packet", r, _packet.size)); + } /* Where we are in the output, in seconds */ double const out_pts_seconds = video_frame_index() / frames_per_second(); -- 2.30.2