private void StartRecording(string savePath) { if (isRecording || isPlaying) { return; } this.savePath = savePath; writer = new VideoWriter(); writer.open(savePath, VideoWriter.fourcc('M', 'J', 'P', 'G'), 30, new Size(Screen.width, Screen.height)); if (!writer.isOpened()) { Debug.LogError("writer.isOpened() false"); writer.release(); return; } screenCapture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false); recordingFrameRgbMat = new Mat(Screen.height, Screen.width, CvType.CV_8UC3); frameCount = 0; isRecording = true; }
public bool SetCodec(string value) { if (value.Length != 4) { return(false); } var fourcc = VideoWriter.fourcc(value[0], value[1], value[2], value[3]); return(capture.set(Videoio.CAP_PROP_FOURCC, fourcc)); }
/// <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'); }