diff --git a/Greenshot/Helpers/AviHelper.cs b/Greenshot/Helpers/AviHelper.cs index 224da01f0..8c7a95e75 100644 --- a/Greenshot/Helpers/AviHelper.cs +++ b/Greenshot/Helpers/AviHelper.cs @@ -250,18 +250,18 @@ namespace Greenshot.Helpers { info.rate = rate; info.suggestedBufferSize = stride * height; - // create stream - if (Avi32.AVIFileCreateStream(file, out stream, ref info) != 0) { - throw new ApplicationException("Failed creating stream"); - } - // describe compression options Avi32.AVICOMPRESSOPTIONS options = new Avi32.AVICOMPRESSOPTIONS(); - + + // create stream + if (Avi32.AVIFileCreateStream(file, out stream, ref info) != 0) { + throw new ApplicationException("Failed creating stream"); + } // uncomment if video settings dialog is required to show + int retCode = 0; if (codec == null) { - int retCode = Avi32.AVISaveOptions( stream, ref options ); + retCode = Avi32.AVISaveOptions( stream, ref options ); if (retCode == 0) { LOG.Debug("Cancel clicked!"); return false; @@ -270,7 +270,8 @@ namespace Greenshot.Helpers { options.handler = Avi32.mmioFOURCC(codec); options.quality = quality; } - + + // create compressed stream int retval = Avi32.AVIMakeCompressedStream(out streamCompressed, stream, ref options, IntPtr.Zero); if (retval != 0) { @@ -320,6 +321,12 @@ namespace Greenshot.Helpers { } } + public void AddEmptyFrame() { + lock (this) { + position++; + } + } + /// /// Add new frame to the AVI file. /// diff --git a/Greenshot/Helpers/CaptureHelper.cs b/Greenshot/Helpers/CaptureHelper.cs index d90b833fc..c741b355f 100644 --- a/Greenshot/Helpers/CaptureHelper.cs +++ b/Greenshot/Helpers/CaptureHelper.cs @@ -728,7 +728,7 @@ namespace Greenshot.Helpers { } if (screenCapture != null) { screenCapture.RecordMouse = capture.CursorVisible; - if (screenCapture.Start(15)) { + if (screenCapture.Start(25)) { return; } // User clicked cancel or a problem occured diff --git a/Greenshot/Helpers/ScreenCaptureHelper.cs b/Greenshot/Helpers/ScreenCaptureHelper.cs index f498e8945..6adc96847 100644 --- a/Greenshot/Helpers/ScreenCaptureHelper.cs +++ b/Greenshot/Helpers/ScreenCaptureHelper.cs @@ -45,6 +45,7 @@ namespace Greenshot.Helpers { private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ScreenCaptureHelper)); private static CoreConfiguration conf = IniConfig.GetIniSection(); private const int MAX_FRAMES = 500; + private const int ALIGNMENT = 8; private IntPtr hWndDesktop = IntPtr.Zero; private IntPtr hDCDesktop = IntPtr.Zero; private IntPtr hDCDest = IntPtr.Zero; @@ -109,13 +110,13 @@ namespace Greenshot.Helpers { LOG.InfoFormat("Starting recording rectangle {0}", recordingRectangle); recordingSize = recordingRectangle.Size; } - if (recordingSize.Width % 8 > 0) { - LOG.InfoFormat("Correcting width to be factor 8, {0} => {1}", recordingSize.Width, recordingSize.Width + (8-(recordingSize.Width % 8))); - recordingSize = new Size(recordingSize.Width + (8-(recordingSize.Width % 8)), recordingSize.Height); + if (recordingSize.Width % ALIGNMENT > 0) { + LOG.InfoFormat("Correcting width to be factor alignment, {0} => {1}", recordingSize.Width, recordingSize.Width + (ALIGNMENT - (recordingSize.Width % ALIGNMENT))); + recordingSize = new Size(recordingSize.Width + (ALIGNMENT - (recordingSize.Width % ALIGNMENT)), recordingSize.Height); } - if (recordingSize.Height % 8 > 0) { - LOG.InfoFormat("Correcting Height to be factor 8, {0} => {1}", recordingSize.Height, recordingSize.Height + (8-(recordingSize.Height % 8))); - recordingSize = new Size(recordingSize.Width, recordingSize.Height + (8-(recordingSize.Height % 8))); + if (recordingSize.Height % ALIGNMENT > 0) { + LOG.InfoFormat("Correcting Height to be factor alignment, {0} => {1}", recordingSize.Height, recordingSize.Height + (ALIGNMENT - (recordingSize.Height % ALIGNMENT))); + recordingSize = new Size(recordingSize.Width, recordingSize.Height + (ALIGNMENT - (recordingSize.Height % ALIGNMENT))); } this.framesPerSecond = framesPerSecond; // "P/Invoke" Solution for capturing the screen @@ -224,7 +225,11 @@ namespace Greenshot.Helpers { msToNextCapture = MSBETWEENCAPTURES; } else { // Compensating - msToNextCapture = Math.Max(0, MSBETWEENCAPTURES - sleeptime); + do { + aviWriter.AddEmptyFrame(); + sleeptime += MSBETWEENCAPTURES; + } while (sleeptime < 0); + msToNextCapture = sleeptime; } } Cleanup();