Captura is not good in terms of performance (does High CPU utilisation and provides mediocre frame rate).
I plan on focusing to improve the performance little by little as I get the time to and note my findings here.
RESULT: Most of the following tasks have been completed and I'm happy with the performance when recording to Media Foundation hardware encoded writer.
[x] Improve Desktop Duplication
Calling AcquireNextFrame immediately after ReleaseFrame on a separate thread seems to be the right way to capture using Desktop Duplication without causing frame drop.
Using TryAcquireNextFrame doesn't throw SharpDXExceptions on timeout.
[x] Revert the order of IBitmapFrame and IBitmapEditor
First generate IBitmapEditor, then run all IOverlays. Then generate IBitmapFrame.
[x] Drop direct Gif encoding support
The direct Gif encoder is not good in terms of performance and file size.
The FFmpeg Gif encoder results in smaller file size but has color blending errors.
I've implemented a Post Processing 2-pass FFmpeg Gif encodng which doesn't seem to have color blending errors. Due to first encoding to x264, it is actually 3-pass.IBitmapFrame.SaveGif method has been removed in #351.
[x] Use Direct2D for manipulating images
When capturing using Desktop Duplication, Direct2D implementation of IEditableFrame is used. (#351)
~Other capture methods still continue to use System.Drawing.Graphics.~
Direct2D is used in place of System.Drawing.Graphics on Windows 8 and above.
[ ] Using FFmpeg as library and not as executable
387 (might not make it)
[x] Using MediaFoundation SinkWriter with Hardware encoding
395
This is the main highlight here. When used with Desktop Duplication, has very low CPU usage.
[x] Use System.Windows.Interop.D3DImage in Preview Window
Preview Window is working for both System.Drawing.Graphics and Direct2D editors in #351.
Webcam should be handled differently from overlays
Since, capturing from webcam takes some time.
[x] Single loop handling recording and writing
At 30fps 1920x1080, CPU usage reduced by almost 6%. This also removes the issue of Captura consuming the whole system RAM when writing is stalled.
Captura is not good in terms of performance (does High CPU utilisation and provides mediocre frame rate). I plan on focusing to improve the performance little by little as I get the time to and note my findings here.
RESULT: Most of the following tasks have been completed and I'm happy with the performance when recording to
Media Foundation
hardware encoded writer.[x] Improve Desktop Duplication Calling
AcquireNextFrame
immediately afterReleaseFrame
on a separate thread seems to be the right way to capture using Desktop Duplication without causing frame drop. UsingTryAcquireNextFrame
doesn't throwSharpDXException
s on timeout.[x] Revert the order of IBitmapFrame and IBitmapEditor First generate
IBitmapEditor
, then run allIOverlays
. Then generateIBitmapFrame
.[x] Drop direct Gif encoding support The direct Gif encoder is not good in terms of performance and file size. The FFmpeg Gif encoder results in smaller file size but has color blending errors. I've implemented a Post Processing 2-pass FFmpeg Gif encodng which doesn't seem to have color blending errors. Due to first encoding to x264, it is actually 3-pass.
IBitmapFrame.SaveGif
method has been removed in #351.[x] Use Direct2D for manipulating images When capturing using Desktop Duplication, Direct2D implementation of
IEditableFrame
is used. (#351) ~Other capture methods still continue to useSystem.Drawing.Graphics
.~Direct2D
is used in place ofSystem.Drawing.Graphics
on Windows 8 and above.[ ] Using FFmpeg as library and not as executable
387 (might not make it)
[x] Using MediaFoundation SinkWriter with Hardware encoding
395
This is the main highlight here. When used with Desktop Duplication, has very low CPU usage.
[x] Use
System.Windows.Interop.D3DImage
in Preview Window Preview Window is working for bothSystem.Drawing.Graphics
andDirect2D
editors in #351.Webcam should be handled differently from overlays Since, capturing from webcam takes some time.
[x] Single loop handling recording and writing At 30fps 1920x1080, CPU usage reduced by almost 6%. This also removes the issue of Captura consuming the whole system RAM when writing is stalled.