internal void StartConversion( string fileName, int topVtiOsdRow, int bottomVtiOsdRow, int leftVtiOsdCol, int rightVtiOsdCol, int firstIntegratedFrameId, int integrationInterval, string cameraModel, string sensorInfo, bool swapTimestampFields, bool dontValidateIntegrationIntervals) { m_VideoController.ClearAAVConversionErrors(); m_Width = m_VideoController.FramePlayer.Video.Width; m_Height = m_VideoController.FramePlayer.Video.Height; m_EndFieldParity = swapTimestampFields ? 1 : 0; m_TestRect = new Rectangle((m_Width / 2) - 16, (m_Height / 2) - 16, 32, 32); m_CurrAavFramePixels = new ushort[m_Width * m_Height]; m_FileName = fileName; m_MaxPixelValue = 0xFF * integrationInterval; m_FirstVtiOsdLine = topVtiOsdRow; m_LastVtiOsdLine = bottomVtiOsdRow; m_LeftVtiOsdCol = leftVtiOsdCol; m_RightVtiOsdCol = rightVtiOsdCol; m_IntegrationPeriod = integrationInterval; m_FirstIntegrationPeriodStartFrameId = firstIntegratedFrameId; m_DontValidateIntegrationIntervals = dontValidateIntegrationIntervals; m_NextExpectedIntegrationPeriodStartFrameId = firstIntegratedFrameId + integrationInterval; m_FramesSoFar = 0; m_Recorder = new AdvRecorder(); m_Recorder.ImageConfig.SetImageParameters( (ushort)m_Width, (ushort)m_Height, 16, m_MaxPixelValue); m_Recorder.FileMetaData.RecorderSoftwareName = "Tangra"; m_Recorder.FileMetaData.RecorderSoftwareVersion = VersionHelper.AssemblyFileVersion; m_Recorder.FileMetaData.CameraModel = !string.IsNullOrWhiteSpace(cameraModel) ? cameraModel : "Unknown"; m_Recorder.FileMetaData.CameraSensorInfo = !string.IsNullOrWhiteSpace(sensorInfo) ? sensorInfo : "Unknown"; var frameRate = 1000.0 / m_VideoController.FramePlayer.Video.MillisecondsPerFrame; m_Recorder.FileMetaData.NativeFrameRate = frameRate; m_Recorder.FileMetaData.EffectiveFrameRate = 1000.0 / (integrationInterval * m_VideoController.FramePlayer.Video.MillisecondsPerFrame); var nativeStandards = string.Empty; if (Math.Abs(frameRate - 25.0) < 0.1) { nativeStandards = "PAL"; } else if (Math.Abs(frameRate - 29.97) < 0.1) { nativeStandards = "NTSC"; } m_Recorder.FileMetaData.AddUserTag("NATIVE-VIDEO-STANDARD", nativeStandards); m_Recorder.FileMetaData.AddUserTag("FRAME-COMBINING", "Binning"); m_Recorder.FileMetaData.AddUserTag("OSD-FIRST-LINE", topVtiOsdRow.ToString()); m_Recorder.FileMetaData.AddUserTag("OSD-LAST-LINE", bottomVtiOsdRow.ToString()); m_Recorder.FileMetaData.AddUserTag("OSD-LEFT-COLUMN", leftVtiOsdCol.ToString()); m_Recorder.FileMetaData.AddUserTag("OSD-RIGHT-COLUMN", rightVtiOsdCol.ToString()); m_Recorder.FileMetaData.AddUserTag("AAV-VERSION", "2"); m_Recorder.FileMetaData.AddUserTag("AAV16-NORMVAL", m_MaxPixelValue.ToString()); m_Recorder.FileMetaData.AddUserTag("INTEGRATION-DETECTION", m_DontValidateIntegrationIntervals ? "Manual" : "Automatic"); m_Recorder.FileMetaData.AddCalibrationStreamTag("TYPE", "VTI-OSD-CALIBRATION"); m_Recorder.FileMetaData.AddCalibrationStreamTag("OSD-FIRST-LINE", topVtiOsdRow.ToString()); m_Recorder.FileMetaData.AddCalibrationStreamTag("OSD-LAST-LINE", bottomVtiOsdRow.ToString()); m_Recorder.FileMetaData.AddCalibrationStreamTag("OSD-LEFT-COLUMN", leftVtiOsdCol.ToString()); m_Recorder.FileMetaData.AddCalibrationStreamTag("OSD-RIGHT-COLUMN", rightVtiOsdCol.ToString()); m_Recorder.StatusSectionConfig.RecordSystemErrors = true; m_Recorder.StatusSectionConfig.AddDefineTag("FRAME-TYPE", Adv2TagType.UTF8String); m_Recorder.StatusSectionConfig.AddDefineTag("FRAMES-IN-INTERVAL", Adv2TagType.Int8); m_Recorder.StatusSectionConfig.AddDefineTag("NOISE-SIGNATURES", Adv2TagType.UTF8String); m_Recorder.StatusSectionConfig.AddDefineTag("ORIGINAL-FRAME-ID", Adv2TagType.Int32); m_Recorder.StartRecordingNewFile(m_FileName, 0, true); int currFrame = m_VideoController.CurrentFrameIndex; try { m_VideoController.SetPictureBoxCursor(Cursors.WaitCursor); m_VideoController.NotifyFileProgress(-1, 16); Pixelmap frame; ushort[] pixels; for (int i = currFrame; i < Math.Min(currFrame + 16, m_VideoController.VideoLastFrame); i++) { frame = m_VideoController.GetFrame(i); pixels = frame.Pixels.Select(x => (ushort)(integrationInterval * x)).ToArray(); m_Recorder.AddCalibrationFrame(pixels, true, PreferredCompression.Lagarith16, new AdvRecorder.AdvStatusEntry() { AdditionalStatusTags = new[] { "VTI-OSD-CALIBRATION", (object)(byte)0, string.Empty, (object)i } }, Adv.AdvImageData.PixelDepth16Bit); m_VideoController.NotifyFileProgress(i - currFrame, 16); } frame = m_VideoController.GetFrame(m_FirstIntegrationPeriodStartFrameId); pixels = frame.Pixels.Select(x => (ushort)(integrationInterval * x)).ToArray(); m_Recorder.AddCalibrationFrame(pixels, true, PreferredCompression.Lagarith16, new AdvRecorder.AdvStatusEntry() { AdditionalStatusTags = new[] { "FIELD-CALIBRATION", (object)(byte)0, string.Empty, (object)m_FirstIntegrationPeriodStartFrameId } }, Adv.AdvImageData.PixelDepth16Bit); } finally { m_VideoController.NotifyFileProgress(-1, 0); m_VideoController.SetPictureBoxCursor(Cursors.Default); } }