diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp
index c631c6fd..0f97586c 100644
--- a/src/FFmpegReader.cpp
+++ b/src/FFmpegReader.cpp
@@ -1142,6 +1142,11 @@ void FFmpegReader::ProcessAudioPacket(long int requested_frame, long int target_
// No other thread is processing it. Mark the audio as processed (final)
processed_audio_frames[f] = f;
}
+
+ if (target_frame == starting_frame_number) {
+ // This typically never happens, but just in case, remove the currently processing number
+ processing_audio_frames.erase(processing_audio_frames.find(target_frame));
+ }
}
// Remove this packet
diff --git a/src/FFmpegWriter.cpp b/src/FFmpegWriter.cpp
index a91d8a73..c9a6eca7 100644
--- a/src/FFmpegWriter.cpp
+++ b/src/FFmpegWriter.cpp
@@ -606,7 +606,7 @@ void FFmpegWriter::flush_encoders()
// Write packet
error_code = av_interleaved_write_frame(oc, &pkt);
- if (error_code != 0) {
+ if (error_code < 0) {
AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code, "", -1, "", -1, "", -1, "", -1, "", -1);
}
@@ -662,7 +662,7 @@ void FFmpegWriter::flush_encoders()
// Write packet
error_code = av_interleaved_write_frame(oc, &pkt);
- if (error_code != 0) {
+ if (error_code < 0) {
AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code, "", -1, "", -1, "", -1, "", -1, "", -1);
}
@@ -1323,7 +1323,7 @@ void FFmpegWriter::write_audio_packets(bool final)
/* write the compressed frame in the media file */
int error_code = av_interleaved_write_frame(oc, &pkt);
- if (error_code != 0)
+ if (error_code < 0)
{
AppendDebugMethod("FFmpegWriter::write_audio_packets ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code, "", -1, "", -1, "", -1, "", -1, "", -1);
}
@@ -1465,7 +1465,7 @@ void FFmpegWriter::write_video_packet(tr1::shared_ptr frame, AVFrame* fra
/* write the compressed frame in the media file */
int error_code = av_interleaved_write_frame(oc, &pkt);
- if (error_code != 0)
+ if (error_code < 0)
{
AppendDebugMethod("FFmpegWriter::write_video_packet ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code, "", -1, "", -1, "", -1, "", -1, "", -1);
throw ErrorEncodingVideo("Error while writing raw video frame", frame->number);
@@ -1538,7 +1538,7 @@ void FFmpegWriter::write_video_packet(tr1::shared_ptr frame, AVFrame* fra
/* write the compressed frame in the media file */
int error_code = av_interleaved_write_frame(oc, &pkt);
- if (error_code != 0)
+ if (error_code < 0)
{
AppendDebugMethod("FFmpegWriter::write_video_packet ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code, "", -1, "", -1, "", -1, "", -1, "", -1);
throw ErrorEncodingVideo("Error while writing compressed video frame", frame->number);
diff --git a/src/FrameMapper.cpp b/src/FrameMapper.cpp
index ff44bbfb..2736181c 100644
--- a/src/FrameMapper.cpp
+++ b/src/FrameMapper.cpp
@@ -661,7 +661,7 @@ void FrameMapper::ResampleMappedAudio(tr1::shared_ptr frame, long int ori
int error_code = avcodec_fill_audio_frame(audio_frame, channels_in_frame, AV_SAMPLE_FMT_S16, (uint8_t *) frame_samples,
audio_frame->nb_samples * av_get_bytes_per_sample(AV_SAMPLE_FMT_S16) * channels_in_frame, 1);
- if (error_code != 0)
+ if (error_code < 0)
{
AppendDebugMethod("FrameMapper::ResampleMappedAudio ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code, "", -1, "", -1, "", -1, "", -1, "", -1);
throw ErrorEncodingVideo("Error while resampling audio in frame mapper", frame->number);