示例#1
0
        void InitializeContext()
        {
            m_num_video_frames = 0;

            // initialize scratch buffer
            UpdateScratchBuffer();

            // initialize context and stream
            {
                m_mp4conf                     = fcAPI.fcMP4Config.default_value;
                m_mp4conf.video               = m_captureVideo;
                m_mp4conf.audio               = m_captureAudio;
                m_mp4conf.video_width         = m_scratch_buffer.width;
                m_mp4conf.video_height        = m_scratch_buffer.height;
                m_mp4conf.video_max_framerate = 60;
                m_mp4conf.video_bitrate       = m_videoBitrate;
                m_mp4conf.audio_bitrate       = m_audioBitrate;
                m_mp4conf.audio_sampling_rate = AudioSettings.outputSampleRate;
                m_mp4conf.audio_num_channels  = fcAPI.fcGetNumAudioChannels();
                m_ctx = fcAPI.fcMP4CreateContext(ref m_mp4conf);

                m_output_file = DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".mp4";
                m_ostream     = fcAPI.fcCreateFileStream(GetOutputPath());
                fcAPI.fcMP4AddOutputStream(m_ctx, m_ostream);
            }

            // initialize command buffer
            {
                m_cb      = new CommandBuffer();
                m_cb.name = "MP4OffscreenRecorder: copy frame buffer";
                m_cb.SetRenderTarget(m_scratch_buffer);
                m_cb.SetGlobalTexture("_TmpRenderTarget", m_target);
                m_cb.DrawMesh(m_quad, Matrix4x4.identity, m_mat_copy, 0, 3);
            }
        }
示例#2
0
        private static fcAPI.fcStream CreateOutputStream(string path, fcAPI.fcMP4Context context)
        {
            fcAPI.fcStream stream = fcAPI.fcCreateFileStream(path);
            fcAPI.fcMP4AddOutputStream(context, stream);

            return(stream);
        }
示例#3
0
        public void BeginRecording()
        {
            if (recording)
            {
                return;
            }

            Reset();

            channels     = GetAudioChannels();
            context      = CreateContext(settings, channels);
            tempFilePath = GetTempFilePath();
            stream       = CreateOutputStream(tempFilePath, context);

            recording = true;
        }
示例#4
0
        void InitializeContext()
        {
            m_num_video_frames = 0;

            // initialize scratch buffer
            UpdateScratchBuffer();

            // initialize context and stream
            {
                m_mp4conf                     = fcAPI.fcMP4Config.default_value;
                m_mp4conf.video               = m_captureVideo;
                m_mp4conf.audio               = m_captureAudio;
                m_mp4conf.video_width         = m_scratch_buffer.width;
                m_mp4conf.video_height        = m_scratch_buffer.height;
                m_mp4conf.video_max_framerate = 60;
                m_mp4conf.video_bitrate       = m_videoBitrate;
                m_mp4conf.audio_bitrate       = m_audioBitrate;
                m_mp4conf.audio_sampling_rate = AudioSettings.outputSampleRate;
                m_mp4conf.audio_num_channels  = fcAPI.fcGetNumAudioChannels();
                m_ctx = fcAPI.fcMP4CreateContext(ref m_mp4conf);

                m_output_file = DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".mp4";
                m_ostream     = fcAPI.fcCreateFileStream(GetOutputPath());
                fcAPI.fcMP4AddOutputStream(m_ctx, m_ostream);
            }

            // initialize command buffer
            {
                int tid = Shader.PropertyToID("_TmpFrameBuffer");
                m_cb      = new CommandBuffer();
                m_cb.name = "MP4Recorder: copy frame buffer";
                m_cb.GetTemporaryRT(tid, -1, -1, 0, FilterMode.Bilinear);
                m_cb.Blit(BuiltinRenderTextureType.CurrentActive, tid);
                m_cb.SetRenderTarget(m_scratch_buffer);
                m_cb.DrawMesh(m_quad, Matrix4x4.identity, m_mat_copy, 0, 0);
                m_cb.ReleaseTemporaryRT(tid);
            }
        }
示例#5
0
        void InitializeContext()
        {
            m_num_video_frames = 0;

            // initialize scratch buffer
            UpdateScratchBuffer();

            // initialize context and stream
            {
                m_mp4conf = fcAPI.fcMP4Config.default_value;
                m_mp4conf.video = m_captureVideo;
                m_mp4conf.audio = m_captureAudio;
                m_mp4conf.video_width = m_scratch_buffer.width;
                m_mp4conf.video_height = m_scratch_buffer.height;
                m_mp4conf.video_max_framerate = 60;
                m_mp4conf.video_bitrate = m_videoBitrate;
                m_mp4conf.audio_bitrate = m_audioBitrate;
                m_mp4conf.audio_sampling_rate = AudioSettings.outputSampleRate;
                m_mp4conf.audio_num_channels = fcAPI.fcGetNumAudioChannels();
                m_ctx = fcAPI.fcMP4CreateContext(ref m_mp4conf);

                m_output_file = DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".mp4";
                m_ostream = fcAPI.fcCreateFileStream(GetOutputPath());
                fcAPI.fcMP4AddOutputStream(m_ctx, m_ostream);
            }

            // initialize command buffer
            {
                int tid = Shader.PropertyToID("_TmpFrameBuffer");
                m_cb = new CommandBuffer();
                m_cb.name = "MP4Recorder: copy frame buffer";
                m_cb.GetTemporaryRT(tid, -1, -1, 0, FilterMode.Bilinear);
                m_cb.Blit(BuiltinRenderTextureType.CurrentActive, tid);
                m_cb.SetRenderTarget(m_scratch_buffer);
                m_cb.DrawMesh(m_quad, Matrix4x4.identity, m_mat_copy, 0, 0);
                m_cb.ReleaseTemporaryRT(tid);
            }
        }
        void InitializeContext()
        {
            m_num_video_frames = 0;

            // initialize scratch buffer
            UpdateScratchBuffer();

            // initialize context and stream
            {
                m_mp4conf = fcAPI.fcMP4Config.default_value;
                m_mp4conf.video = m_captureVideo;
                m_mp4conf.audio = m_captureAudio;
                m_mp4conf.video_width = m_scratch_buffer.width;
                m_mp4conf.video_height = m_scratch_buffer.height;
                m_mp4conf.video_max_framerate = 60;
                m_mp4conf.video_bitrate = m_videoBitrate;
                m_mp4conf.audio_bitrate = m_audioBitrate;
                m_mp4conf.audio_sampling_rate = AudioSettings.outputSampleRate;
                m_mp4conf.audio_num_channels = fcAPI.fcGetNumAudioChannels();
                m_ctx = fcAPI.fcMP4CreateContext(ref m_mp4conf);

                m_output_file = DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".mp4";
                m_ostream = fcAPI.fcCreateFileStream(GetOutputPath());
                fcAPI.fcMP4AddOutputStream(m_ctx, m_ostream);
            }

            // initialize command buffer
            {
                m_cb = new CommandBuffer();
                m_cb.name = "MP4OffscreenRecorder: copy frame buffer";
                m_cb.SetRenderTarget(m_scratch_buffer);
                m_cb.SetGlobalTexture("_TmpRenderTarget", m_target);
                m_cb.DrawMesh(m_quad, Matrix4x4.identity, m_mat_copy, 0, 3);
            }
        }