コード例 #1
0
        protected internal override void RecordFrame(RecordingSession session)
        {
            if (m_Inputs.Count != 1)
            {
                throw new Exception("Unsupported number of sources");
            }

            var input = (BaseRenderTextureInput)m_Inputs[0];
            var frame = input.OutputRenderTexture;

            if (!m_ctx)
            {
                var s = Settings.m_MP4EncoderSettings;
                s.video                = true;
                s.audio                = false;
                s.videoWidth           = frame.width;
                s.videoHeight          = frame.height;
                s.videoTargetFramerate = (int)Math.Ceiling(Settings.FrameRate);
                if (Settings.m_AutoSelectBR)
                {
                    s.videoTargetBitrate = (int)(((frame.width * frame.height / 1000.0) / 245 + 1.16) * (s.videoTargetFramerate / 48.0 + 0.5) * 1000000);
                }
                var path = Settings.fileNameGenerator.BuildAbsolutePath(session);
                m_ctx = fcAPI.fcMP4OSCreateContext(ref s, path);
            }

            fcAPI.fcLock(frame, TextureFormat.RGB24, (data, fmt) =>
            {
                fcAPI.fcMP4AddVideoFramePixels(m_ctx, data, fmt, session.recorderTime);
            });
        }
コード例 #2
0
        public override void Initialize(object config, string outPath)
        {
            if (!fcAPI.fcMP4OSIsSupported())
            {
                Debug.LogError("MP4 encoder is not available on this platform.");
                return;
            }

            m_config = (fcAPI.fcMP4Config)config;
            m_config.audioSampleRate  = AudioSettings.outputSampleRate;
            m_config.audioNumChannels = fcAPI.fcGetNumAudioChannels();

            var path = outPath + ".mp4";

            m_ctx = fcAPI.fcMP4OSCreateContext(ref m_config, path);
        }