public void StartRecording(string filepath) { // Start recording. // We always record what is displayed on screen, not what is grabbed by the device. // Restart capturing if needed. if (!m_FrameGrabber.IsGrabbing) { m_FrameGrabber.StartGrabbing(); } // Open a recording context. int interval = 40; InfosVideo iv = new InfosVideo(); // The FileWriter will currently only use the original size due to some problems. // Most notably, DV video passed into 16:9 (720x405) crashes swscale(). iv.iWidth = m_FrameGrabber.FrameSize.Width; iv.iHeight = m_FrameGrabber.FrameSize.Height; if (m_FrameGrabber.FramesInterval > 0) { // Hack. For interlaced video, we get the fields interval, which is half the frame interval. interval = m_FrameGrabber.FramesInterval * 2; } SaveResult result = m_VideoFileWriter.OpenSavingContext(filepath, iv, interval, false); if (result == SaveResult.Success) { // The frames will be pushed to the file upon receiving the FrameGrabbed event. m_bCaptureThumbSet = false; m_bIsRecording = true; } else { m_VideoFileWriter.CloseSavingContext(false); m_bIsRecording = false; DisplayError(result); } }
public SaveResult Initialize(string _filepath, double _interval, Size _FrameSize) { // Open the recording context and start the recording thread. // The thread will then wait for the first frame to drop in. // FIXME: The FileWriter will currently only use the original size due to some problems. // Most notably, DV video passed into 16:9 (720x405) crashes swscale(). // TODO: Check if this is due to non even height. InfosVideo iv = new InfosVideo(); iv.iWidth = _FrameSize.Width; iv.iHeight = _FrameSize.Height; SaveResult result = m_VideoFileWriter.OpenSavingContext(_filepath, iv, _interval, false); if (result == SaveResult.Success) { m_bInitialized = true; m_bCaptureThumbSet = false; m_WorkerThread.Start(); } else { try { m_VideoFileWriter.CloseSavingContext(false); } catch (Exception exp) { // Saving context couldn't be opened properly. Depending on failure we might also fail at trying to close it again. log.Error(exp.Message); log.Error(exp.StackTrace); } } return(result); }