void Awake() { Application.runInBackground = true; DanbiComputeShader.onSampleFinished += (RenderTexture converged_resultRT) => m_distortedRT = converged_resultRT; // Should it be also added in DanbiImageWriter.cs?? **MOON** DanbiUIVideoGeneratorGeneratePanel.onVideoSave += () => m_isSaving = true; DanbiUIVideoGeneratorVideoPanel.onVideoPathAndNameChange += (string videoName) => m_vidName = videoName; DanbiUIVideoGeneratorFileOptionPanel.onVideoExtChange += (EDanbiVideoExt ext) => m_videoExt = ext; DanbiUIVideoGeneratorFileOptionPanel.onVideoCodecChange += (EDanbiOpencvCodec_fourcc_ codec) => m_videoCodec = codec; DanbiUIVideoGeneratorFileOptionPanel.onTargetFrameRateChange += (int targetFrameRate) => m_targetFrameRate = targetFrameRate; DanbiUIVideoGeneratorFileOptionPanel.onSavedVideoPathAndNameChange += (string savedVideoPathAndName) => m_savedVideoPathAndName = savedVideoPathAndName; DanbiUIVideoGeneratorFileOptionPanel.onSavedVideoPathChange += (string videoPath) => m_savedVideoPath = videoPath; }
protected override void LoadPreviousValues(params Selectable[] uiElements) { // load previous video path string prevVidPathOnly = PlayerPrefs.GetString("VideoGeneratorFileOption-vidPath", default); if (!string.IsNullOrEmpty(prevVidPathOnly)) { m_videoPath = prevVidPathOnly; Panel.transform.GetChild(5).GetComponent <TMP_Text>().text = m_videoPath; onSavedVideoPathChange?.Invoke(m_videoPath); } // load previous video name string prevVidNameOnly = PlayerPrefs.GetString("VideoGeneratorFileOption-vidNameOnly", default); if (!string.IsNullOrEmpty(prevVidNameOnly)) { m_videoName = prevVidNameOnly; Panel.transform.GetChild(1).GetComponent <TMP_InputField>().text = m_videoName; } // load previous video (format)extension var prevVidExtOnly = (EDanbiVideoExt)PlayerPrefs.GetInt("VideoGeneratorFileOption-vidExtOnly", default); m_videoExt = prevVidExtOnly; Panel.transform.GetChild(2).GetComponent <TMP_Dropdown>().value = (int)m_videoExt; onVideoExtChange?.Invoke(m_videoExt); // load previous video codec. var prevVidCodec = (EDanbiOpencvCodec_fourcc_)PlayerPrefs.GetInt("VideoGeneratorFileOption-vidCodec", default); m_videoCodec = prevVidCodec; Panel.transform.GetChild(3).GetComponent <TMP_Dropdown>().value = (int)m_videoCodec; onVideoCodecChange?.Invoke(m_videoCodec); // load previous target frame rate. var prevTargetFrameRate = PlayerPrefs.GetInt("VideoGeneratorFileOption-targetFrameRate", default); m_targetFrameRate = prevTargetFrameRate; Panel.transform.GetChild(4).GetComponent <TMP_InputField>().text = m_targetFrameRate.ToString(); onTargetFrameRateChange?.Invoke(m_targetFrameRate); }
/// <summary> /// make fourcc form of videoCodec! /// (-999 -> error) /// </summary> /// <param name="codec"></param> /// <returns></returns> public static int get_fourcc_videoCodec(EDanbiOpencvCodec_fourcc_ codec) { // switch (codec) // { // case EDanbiOpencvCodec_fourcc_.h264: // return VideoWriter.fourcc('X', '2', '6', '4'); // case EDanbiOpencvCodec_fourcc_.h265: // case EDanbiOpencvCodec_fourcc_.hevc: // return VideoWriter.fourcc('H', 'E', 'V', 'C'); // case EDanbiOpencvCodec_fourcc_.mpeg4: // return VideoWriter.fourcc('M', 'P', '4', '2'); // case EDanbiOpencvCodec_fourcc_.divx: // return VideoWriter.fourcc('D', 'I', 'V', 'X'); // default: // return -999; // } // return VideoWriter.fourcc('M', 'J', 'P', 'G'); -> error to write a video return(VideoWriter.fourcc('D', 'I', 'V', 'X')); // return VideoWriter.fourcc('X', '2', '6', '4'); }
protected override void AddListenerForPanelFields() { base.AddListenerForPanelFields(); var panel = Panel.transform; // bind video save location text var videoSaveLocationText = panel.GetChild(5).GetComponent <TMP_Text>(); // bind video save path button. var vidSavePathButton = panel.GetChild(0).GetComponent <Button>(); vidSavePathButton.onClick.AddListener(() => StartCoroutine(Coroutine_SaveFilePath(videoSaveLocationText))); // bind video name inputfield. var vidNameInputField = panel.GetChild(1).GetComponent <TMP_InputField>(); vidNameInputField.onValueChanged.AddListener( (string val) => { m_videoName = val; videoSaveLocationText.text = $"File Location : {m_savePathAndName}"; } ); // bind video extension dropdown var vidExtOptions = new List <string> { ".mp4", ".avi", "m4v", ".mov", ".webm", ".wmv" }; var vidExtDropdown = panel.GetChild(2).GetComponent <TMP_Dropdown>(); vidExtDropdown.AddOptions(vidExtOptions); vidExtDropdown.onValueChanged.AddListener( (int option) => { // vidExtOnly = vidExtOptions[option]; m_videoExt = (EDanbiVideoExt)option; onVideoExtChange?.Invoke(m_videoExt); videoSaveLocationText.text = $"File Location : {m_savePathAndName}"; } ); // bind video codect dropdown var vidCodecOptions = new List <string> { "h264", "h265", "divx", "mpeg4", "hevc" }; var vidCodecDropdown = panel.GetChild(3).GetComponent <TMP_Dropdown>(); vidCodecDropdown.AddOptions(vidCodecOptions); vidCodecDropdown.onValueChanged.AddListener( (int option) => { m_videoCodec = (EDanbiOpencvCodec_fourcc_)option; onVideoCodecChange?.Invoke(m_videoCodec); } ); // bind video target frame rate var vidTargetFrameRateInputField = panel.GetChild(4).GetComponent <TMP_InputField>(); vidTargetFrameRateInputField.onValueChanged.AddListener( (string val) => { if (int.TryParse(val, out var res)) { m_targetFrameRate = res; onTargetFrameRateChange?.Invoke(m_targetFrameRate); } } ); LoadPreviousValues(); }