Esempio n. 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);
            }
        }
Esempio n. 2
0
        private static fcAPI.fcMP4Context CreateContext(MP4EncoderSettings settings, int channels)
        {
            fcAPI.fcMP4Config config = fcAPI.fcMP4Config.default_value;
            config.video               = settings.CaptureVideo;
            config.audio               = settings.CaptureAudio;
            config.video_width         = settings.ResolutionWidth;
            config.video_height        = settings.ResolutionHeight;
            config.video_max_framerate = 60;
            config.video_bitrate       = settings.VideoBitrate;
            config.audio_bitrate       = settings.AudioBitrate;
            config.audio_sampling_rate = AudioSettings.outputSampleRate;
            config.audio_num_channels  = channels;

            return(fcAPI.fcMP4CreateContext(ref config));
        }
Esempio n. 3
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);
            }
        }
Esempio n. 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);
            }
        }
        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);
            }
        }