From 547a0dbc63ffd2953e5646526670a596a4800369 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Sun, 18 Nov 2012 10:45:16 -0600 Subject: [PATCH] Improved the flush_encoders method to not raise errors if it encounters errors encoding NULL AVFrames. --- src/FFmpegWriter.cpp | 23 ++++++++--------------- src/Main.cpp | 2 +- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/FFmpegWriter.cpp b/src/FFmpegWriter.cpp index 977b95eb..9af57b37 100644 --- a/src/FFmpegWriter.cpp +++ b/src/FFmpegWriter.cpp @@ -517,8 +517,8 @@ void FFmpegWriter::flush_encoders() error_description = av_err2str(error_code); #endif - cout << "error: " << error_code << ": " << error_description << endl; - throw ErrorEncodingVideo("Error while flushing video frame", -1); + cout << "error encoding video: " << error_code << ": " << error_description << endl; + //throw ErrorEncodingVideo("Error while flushing video frame", -1); } if (!got_packet) { stop_encoding = 1; @@ -546,8 +546,8 @@ void FFmpegWriter::flush_encoders() error_description = av_err2str(error_code); #endif - cout << "error: " << error_code << ": " << error_description << endl; - throw ErrorEncodingVideo("Error while writing video packet to flush encoder", -1); + cout << "error writing video: " << error_code << ": " << error_description << endl; + //throw ErrorEncodingVideo("Error while writing video packet to flush encoder", -1); } // Deallocate memory (if needed) @@ -580,8 +580,8 @@ void FFmpegWriter::flush_encoders() error_description = av_err2str(error_code); #endif - cout << "error: " << error_code << ": " << error_description << endl; - throw ErrorEncodingAudio("Error while flushing audio frame", -1); + cout << "error encoding audio: " << error_code << ": " << error_description << endl; + //throw ErrorEncodingAudio("Error while flushing audio frame", -1); } if (!got_packet) { stop_encoding = 1; @@ -613,8 +613,8 @@ void FFmpegWriter::flush_encoders() error_description = av_err2str(error_code); #endif - cout << "error: " << error_code << ": " << error_description << endl; - throw ErrorEncodingAudio("Error while writing audio packet to flush encoder", -1); + cout << "error writing audio: " << error_code << ": " << error_description << endl; + //throw ErrorEncodingAudio("Error while writing audio packet to flush encoder", -1); } } @@ -720,13 +720,6 @@ AVStream* FFmpegWriter::add_audio_stream() c->bit_rate = info.audio_bit_rate; c->channels = info.channels; - // Check for valid timebase -// if (c->time_base.den == 0 || c->time_base.num == 0) -// { -// c->time_base.num = st->time_base.num; -// c->time_base.den = st->time_base.den; -// } - // Set valid sample rate (or throw error) if (codec->supported_samplerates) { int i; diff --git a/src/Main.cpp b/src/Main.cpp index 030ce3e6..87aa7818 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -57,7 +57,7 @@ int main() Timeline t(640, 360, Framerate(24,1), 44100, 2); // Add some clips - Clip c1(new FFmpegReader("/home/jonathan/Videos/sintel-1024-stereo.mp4")); + Clip c1(new FFmpegReader("/home/jonathan/Videos/sintel_trailer-480p.mp4")); Clip c2(new ImageReader("/home/jonathan/Desktop/logo1.png")); Clip c3(new ImageReader("/home/jonathan/Desktop/logo1.png")); //Clip c3(new FFmpegReader("/home/jonathan/Desktop/IncognitoCory_-_April_Song.mp3"));