diff --git a/include/FFmpegWriter.h b/include/FFmpegWriter.h index f748a124..ab6a5f98 100644 --- a/include/FFmpegWriter.h +++ b/include/FFmpegWriter.h @@ -57,6 +57,7 @@ namespace openshot string path; int cache_size; bool is_writing; + int64 write_frame_count; AVOutputFormat *fmt; AVFormatContext *oc; diff --git a/src/FFmpegWriter.cpp b/src/FFmpegWriter.cpp index 52f56c86..dc5c5f78 100644 --- a/src/FFmpegWriter.cpp +++ b/src/FFmpegWriter.cpp @@ -30,8 +30,8 @@ using namespace openshot; FFmpegWriter::FFmpegWriter(string path) throw (InvalidFile, InvalidFormat, InvalidCodec, InvalidOptions, OutOfMemory) : path(path), fmt(NULL), oc(NULL), audio_st(NULL), video_st(NULL), audio_pts(0), video_pts(0), samples(NULL), audio_outbuf(NULL), audio_outbuf_size(0), audio_input_frame_size(0), audio_input_position(0), - initial_audio_input_frame_size(0), resampler(NULL), img_convert_ctx(NULL), cache_size(8), - num_of_rescalers(32), rescaler_position(0), video_codec(NULL), audio_codec(NULL), is_writing(false) + initial_audio_input_frame_size(0), resampler(NULL), img_convert_ctx(NULL), cache_size(8), num_of_rescalers(32), + rescaler_position(0), video_codec(NULL), audio_codec(NULL), is_writing(false), write_frame_count(0) { // Init FileInfo struct (clear all values) @@ -502,6 +502,9 @@ void FFmpegWriter::Close() avio_close(oc->pb); } + // Reset frame counter + write_frame_count = 0; + // Free the stream av_free(oc); } @@ -1032,6 +1035,7 @@ void FFmpegWriter::write_video_packet(tr1::shared_ptr frame, AVFrame* fra /* write the compressed frame in the media file */ int averror = av_write_frame(oc, &pkt); + //int averror = av_interleaved_write_frame(oc, &pkt); if (averror != 0) { //string error_description = av_err2str(averror);