同步操作将从 OpenHarmony/docs 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
Audio and video recording is used to record audio and video and encapsulate output files based on the configured encoding format, sampling rate, and bit rate.
The audio and video recording APIs are as follows. For details about the APIs, see the interface document.
Table 1 Audio and Video Recording APIs
None
This API is used to create a Recorder instance.
Recorder *recorder = Recorder::CreateRecorder();
Sets Recorder parameters, including the audio and video source information, audio and video encoding format, sampling rate, bit rate, and video width and height.
int32_t sampleRate = 48000;
int32_t channelCount = 1;
AudioCodecFormat audioFormat = AAC_LC;
AudioSourceType inputSource = AUDIO_MIC;
int32_t audioEncodingBitRate = sampleRate;
VideoSourceType source = VIDEO_SOURCE_SURFACE_ES;
int32_t frameRate = 30;
float fps = 30;
int32_t rate = 4096;
int32_t sourceId = 0;
int32_t audioSourceId = 0;
int32_t width = 1920;
int32_t height = 1080;
VideoCodecFormat encoder = H264;
recorder->SetVideoSource(source, sourceId); // Set the video source and obtain the sourceId.
recorder->SetVideoEncoder(sourceId, encoder); // Set the video encoding format.
recorder->SetVideoSize(sourceId, width, height); // Set the video width and height.
recorder->SetVideoFrameRate(sourceId, frameRate); // Set the video frame rate.
recorder->SetVideoEncodingBitRate(sourceId, rate); //: Sets the video encoding bit rate.
recorder->SetCaptureRate(sourceId, frameRate); //: Sets the frame capture rate of video frames.
recorder->SetAudioSource(inputSource, audioSourceId); // Set the audio source and obtain audioSourceId.
recorder->SetAudioEncoder(audioSourceId, audioFormat); // Set the audio encoding format.
recorder->SetAudioSampleRate(audioSourceId, sampleRate); // Set the audio sampling rate.
recorder->SetAudioChannels(audioSourceId, channelCount); // Set the number of audio channels.
recorder->SetAudioEncodingBitRate(audioSourceId, audioEncodingBitRate); // Set the audio encoding bit rate.
Prepare for the recording. The Recorder prepares for the recording.
recorder->Prepare(); // Prepares for recording.
The Recorder starts recording based on the configured audio and video sources.
recorder->Start(); // Start recording.
Stop recording and release resources.
recorder->Stop(); // Stop recording.
recorder->Release(); // Release recording resources.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。