Esempio n. 1
0
        public SaveResult Prepare(string filename, double interval)
        {
            if (imageDescriptor == null)
            {
                throw new NotSupportedException("ImageDescriptor must be set before prepare.");
            }

            this.filename = filename;

            if (writer != null)
            {
                writer.Dispose();
            }

            writer = new MJPEGWriter();

            VideoInfo info = new VideoInfo();

            info.OriginalSize = new Size(imageDescriptor.Width, imageDescriptor.Height);

            string formatString = FilenameHelper.GetFormatStringCapture();

            // If the capture happens at more than 100fps, set the video itself to be at 30fps.
            // This avoids erratic playback because the player can't cope with the framerate, drawback: prevents review in real time.
            // FIXME: fix the player so that it can playback high speed video in real time.
            if (interval < 10)
            {
                interval = 1000.0 / 30;
            }

            SaveResult result = writer.OpenSavingContext(filename, info, formatString, interval);

            return(result);
        }
Esempio n. 2
0
        public SaveResult StartRecord(string filename, double interval)
        {
            //-----------------------
            // Runs on the UI thread.
            //-----------------------

            if (imageDescriptor == null)
            {
                throw new NotSupportedException("ImageDescriptor must be set before prepare.");
            }

            this.filename = filename;

            if (writer != null)
            {
                writer.Dispose();
            }

            writer = new MJPEGWriter();

            VideoInfo info = new VideoInfo();

            info.OriginalSize = new Size(imageDescriptor.Width, imageDescriptor.Height);

            bool   uncompressed = PreferencesManager.CapturePreferences.SaveUncompressedVideo && imageDescriptor.Format != ImageFormat.JPEG;
            string formatString = FilenameHelper.GetFormatStringCapture(uncompressed);

            // If the capture happens too fast or too slow for a regular player, set the video metadata to a more sensible framerate.
            // This avoids erratic playback because the player can't cope with the framerate, drawback: prevents review in real time.
            double hrft         = PreferencesManager.CapturePreferences.HighspeedRecordingFramerateThreshold;
            double srft         = PreferencesManager.CapturePreferences.SlowspeedRecordingFramerateThreshold;
            double fps          = 1000.0 / interval;
            double fileInterval = interval;

            if (fps >= hrft)
            {
                double hrfo = PreferencesManager.CapturePreferences.HighspeedRecordingFramerateOutput;
                fileInterval = 1000.0 / hrfo;
                log.DebugFormat("High speed recording detected, {0:0.###} fps. Forcing output framerate to {1:0.###} fps.", fps, hrfo);
            }
            else if (fps <= srft)
            {
                double srfo = PreferencesManager.CapturePreferences.SlowspeedRecordingFramerateOutput;
                fileInterval = 1000.0 / srfo;
                log.DebugFormat("Slow speed recording detected, {0:0.###} fps. Forcing output framerate to {1:0.###} fps.", fps, srfo);
            }


            log.DebugFormat("Frame budget for writer [{0}]: {1:0.000} ms.", shortId, interval);

            SaveResult result = writer.OpenSavingContext(filename, info, formatString, imageDescriptor.Format, uncompressed, interval, fileInterval);

            recording = true;

            return(result);
        }
Esempio n. 3
0
        public SaveResult StartRecord(string filename, double interval, ImageRotation rotation)
        {
            //-----------------------
            // Runs on the UI thread.
            //-----------------------

            if (imageDescriptor == null)
            {
                throw new NotSupportedException("ImageDescriptor must be set before prepare.");
            }

            this.filename = filename;

            if (writer != null)
            {
                writer.Dispose();
            }

            writer = new MJPEGWriter();

            VideoInfo info = new VideoInfo();

            info.OriginalSize = new Size(imageDescriptor.Width, imageDescriptor.Height);

            bool   uncompressed = PreferencesManager.CapturePreferences.SaveUncompressedVideo && imageDescriptor.Format != ImageFormat.JPEG;
            string formatString = FilenameHelper.GetFormatStringCapture(uncompressed);
            double fileInterval = CalibrationHelper.ComputeFileFrameInterval(interval);

            log.DebugFormat("Frame budget for writer [{0}]: {1:0.000} ms.", shortId, interval);

            SaveResult result = writer.OpenSavingContext(filename, info, formatString, imageDescriptor.Format, uncompressed, interval, fileInterval, rotation);

            recording = true;

            return(result);
        }