Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can i create an avi video file in real time while my application is processing?
    primarykey
    data
    text
    <p>Edit:</p> <p>This is what i did: In Form1:</p> <pre><code>ScreenCapture sc; AviFile af; </code></pre> <p>In Form1 constructor:</p> <pre><code>sc = new ScreenCapture(); af = new AviFile(); </code></pre> <p>In Form1 timer1 tick event:</p> <pre><code>private void timer1_Tick(object sender, EventArgs e) { if (playImages == true) { timer1.Enabled = false; play(); timer1.Enabled = true; } else { af.CreateAvi(this.sc); } } </code></pre> <p>The AviFile class after changed it:</p> <pre><code>using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Windows.Forms; using AviFile; using ScreenShotDemo; namespace ScreenVideoRecorder { class AviFile { AviManager aviManager; Bitmap bmp; public AviFile() { aviManager = new AviManager(@"d:\testdata\new.avi", false); } public void CreateAvi(ScreenCapture sc) { bmp = new Bitmap(sc.CaptureScreen()); VideoStream aviStream = aviManager.AddVideoStream(false, 25, bmp);//dlg.Rate, bmp); aviStream.AddFrame(bmp); bmp.Dispose(); } public AviManager avim { get { return aviManager; } set { aviManager = value; } } } } </code></pre> <p>In Form1 button click event to stop:</p> <pre><code>private void button3_Click(object sender, EventArgs e) { timer1.Enabled = false; if (af != null) { af.avim.Close(); } } </code></pre> <p>But before i stop it after running it after few seconds of taking screenshots: This is button1 wich start the timer and take screenshots:</p> <pre><code>private void button1_Click(object sender, EventArgs e) { playImages = false; timer1.Enabled = true; } </code></pre> <p>After few seconds im getting an exception:</p> <pre><code>Exception in AVIFileCreateStream: -2147205019 System.Exception was unhandled HResult=-2146233088 Message=Exception in AVIFileCreateStream: -2147205019 Source=AviFile StackTrace: at AviFile.VideoStream.CreateStreamWithoutFormat() at AviFile.VideoStream.CreateStream() at AviFile.VideoStream..ctor(Int32 aviFile, Boolean writeCompressed, Double frameRate, Bitmap firstFrame) at AviFile.AviManager.AddVideoStream(Boolean isCompressed, Double frameRate, Bitmap firstFrame) at ScreenVideoRecorder.AviFile.CreateAvi(ScreenCapture sc) in d:\C-Sharp\ScreenVideoRecorder\ScreenVideoRecorder\ScreenVideoRecorder\AviFile.cs:line 27 at ScreenVideoRecorder.Form1.timer1_Tick(Object sender, EventArgs e) in d:\C-Sharp\ScreenVideoRecorder\ScreenVideoRecorder\ScreenVideoRecorder\Form1.cs:line 61 at System.Windows.Forms.Timer.OnTick(EventArgs e) at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message&amp; m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp; msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at ScreenVideoRecorder.Program.Main() in d:\C-Sharp\ScreenVideoRecorder\ScreenVideoRecorder\ScreenVideoRecorder\Program.cs:line 19 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: </code></pre> <p>The exception is in the class : VideoStream wich is not my class it's from the site i downloaded the source files: <a href="http://www.codeproject.com/Articles/7388/A-Simple-C-Wrapper-for-the-AviFile-Library" rel="nofollow">http://www.codeproject.com/Articles/7388/A-Simple-C-Wrapper-for-the-AviFile-Library</a></p> <p>How can i fix it ?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload