同步操作将从 OpenHarmony/docs 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
To record audios and videos, use APIs described in this section to set the encoding format, sampling rate, and bit rate, and encapsulate output files based on the parameters.
The following table describes APIs available for audio and video recording.
Table 1 APIs available for media recording
None
Create a Recorder instance.
Recorder *recorder = new Recorder();
Sets parameters for the Recorder instance, including the media source information, 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;
double 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 source ID.
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); // Set the video encoding bit rate.
recorder->SetCaptureRate(sourceId, fps); // Set the capture rate for video frames.
recorder->SetAudioSource(inputSource, audioSourceId); // Set the audio source and obtain the source ID.
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 the Recorder instance for recording.
recorder->Prepare(); // Prepare for recording.
Start recording. The Recorder instance starts recording based on the audio and video sources.
recorder->Start(); // Start recording.
Stop recording and release resources.
recorder->Stop(); // Stop recording.
recorder->Release(); // Release recording resources.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。