openharmony 鸿蒙 arkts-apis-media-i

2026-08-25 浏览 (1)

Interfaces (Others)

NOTE

The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.

AVFileDescriptor9+

Describes an audio and video file asset. It is used to specify a particular asset for playback based on its offset and length within a file.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.Multimedia.Media.Core

NameTypeRead-OnlyOptionalDescription
fdnumberNoNoResource handle, which is obtained by calling resourceManager.getRawFd or fileIo.open.
offsetnumberNoYesResource offset.
The value ranges from 0 to the size of the audio/video file to be played. The default value is 0. The value needs to be entered based on the preset resource information. An invalid value causes a failure to parse audio and video resources.
lengthnumberNoYesResource length.
The value ranges from 0 to the size of the audio or video file to be played. The default value is the number of remaining bytes starting from the offset in the file. The value needs to be entered based on the preset resource information. An invalid value causes a failure to parse audio and video resources.

AVDataSrcDescriptor10+

Defines the descriptor of an audio and video file, which is used in DataSource playback mode.
Use scenario: An application can create a playback instance and start playback before it finishes downloading the audio and video resources.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.Multimedia.Media.AVPlayer

NameTypeRead-OnlyOptionalDescription
fileSizenumberNoNoSize of the file to play, in bytes. The value -1 indicates that the size is unknown. If fileSize is set to -1, the playback mode is similar to the live mode. In this mode, the seek and setSpeed operations cannot be performed, and the loop property cannot be set, indicating that loop playback is unavailable.
callback(buffer: ArrayBuffer, length: number, pos?: number) => numberNoNoCallback used to fill in data.
- buffer: memory to be filled. This parameter is mandatory.
- length: maximum length of the memory to be filled. This parameter is mandatory.
- pos: position of the data to be filled in the file. This parameter is optional. When fileSize is set to -1, this parameter cannot be used.
- Return value: length of the data filled, which is of the number type. If -1 is returned, the end of stream is reached. If -2 is returned, an unrecoverable error occurs.

SubtitleInfo12+

Describes the external subtitle information. When a subtitle update event is subscribed to, the information about the external subtitle is returned through a callback.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Multimedia.Media.Core

NameTypeRead-OnlyOptionalDescription
textstringNoYesText information of the subtitle.
startTimenumberNoYesStart time for displaying the subtitle, in milliseconds.
durationnumberNoYesDuration for displaying the subtitle, in milliseconds.

SeiMessage18+

Describes the information of an SEI message.

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.Multimedia.Media.Core

NameTypeRead-OnlyOptionalDescription
payloadTypenumberNoNoPayload type of the SEI message.
payloadArrayBufferNoNoPayload data of the SEI message.

MediaDescription8+

Defines media information in key-value mode.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.Multimedia.Media.Core

NameTypeRead-OnlyOptionalDescription
[key: string]ObjectNoYesFor details about the key range supported and the object type and range of each key, see MediaDescriptionKey.

Example

import { BusinessError } from '@kit.BasicServicesKit';
import { media } from '@kit.MediaKit';

function printfItemDescription(obj: media.MediaDescription, key: string) {
  let property: Object = obj[key];
  console.info('audio key is ' + key); // Obtain the value of the key. For details about the keys, see MediaDescriptionKey.
  console.info('audio value is ' + property); // Obtain the value of the key. The value can be any type. For details about the types, see MediaDescriptionKey.
}

let avPlayer: media.AVPlayer|undefined = undefined;
media.createAVPlayer((err: BusinessError, player: media.AVPlayer) => {
  if(player != null) {
    avPlayer = player;
    console.info(`Succeeded in creating AVPlayer`);
    avPlayer.getTrackDescription((error: BusinessError, arrList: Array<media.MediaDescription>) => {
      if (arrList != null) {
        for (let i = 0; i < arrList.length; i++) {
          printfItemDescription(arrList[i], media.MediaDescriptionKey.MD_KEY_TRACK_TYPE); // Print the MD_KEY_TRACK_TYPE value of each track.
        }
      } else {
        console.error(`Failed to get TrackDescription, error:${error}`);
      }
    });
  } else {
    console.error(`Failed to create AVPlayer, error message:${err.message}`);
  }
});

PlaybackInfo12+

Defines the playback information in key-value pairs.

System capability: SystemCapability.Multimedia.Media.Core

NameTypeRead-OnlyOptionalDescription
[key: string]ObjectNoYesFor details about the value range of each key, see PlaybackInfoKey.
For details about the object type and range of each key, see PlaybackInfoKey.

AVRecorderConfig9+

Describes the audio and video recording parameters.

The audioSourceType and videoSourceType parameters are used to distinguish audio-only recording, video-only recording, and audio and video recording. For audio-only recording, set only audioSourceType. For video-only recording, set only videoSourceType. For audio and video recording, set both audioSourceType and videoSourceType.

System capability: SystemCapability.Multimedia.Media.AVRecorder

NameTypeRead-OnlyOptionalDescription
audioSourceTypeAudioSourceTypeNoYesType of the audio source to record. This parameter is mandatory for audio recording.
Atomic service API: This API can be used in atomic services since API version 12.
videoSourceTypeVideoSourceTypeNoYesType of the video source to record. This parameter is mandatory for video recording.
profileAVRecorderProfileNoNoRecording profile. This parameter is mandatory.
Atomic service API: This API can be used in atomic services since API version 12.
urlstringNoNoRecording output URL: fd://xx (fd number).
img
This parameter is mandatory.
Atomic service API: This API can be used in atomic services since API version 12.
fileGenerationMode12+FileGenerationModeNoYesMode for creating the file, which is used together with on('photoAssetAvailable').
rotation(deprecated)numberNoYesRotation angle of the recorded video. The value can be 0 (default), 90, 180, or 270 for MP4 videos.
This API is supported since API version 6 and deprecated since API version 12. You are advised to use AVMetadata.videoOrientation instead.
If both parameters are set, AVMetadata.videoOrientation is used.
location(deprecated)LocationNoYesGeographical location of the recorded video. By default, the geographical location information is not recorded.
This API is supported since API version 6 and deprecated since API version 12. You are advised to use AVMetadata.location instead.
If both parameters are set, AVMetadata.location is used.
metadata12+AVMetadataNoYesMetadata. For details, see AVMetadata.
maxDuration18+numberNoYesMaximum recording duration, in seconds. The value range is [1, 2^31-1]. If an invalid value is provided, it is reset to the maximum allowed duration. Once the recording reaches the specified duration, it stops automatically and notifies via the stateChange callback that the recording has stopped: AVRecorderState = 'stopped', StateChangeReason = BACKGROUND.

AVRecorderProfile9+

Describes the audio and video recording profile.

System capability: SystemCapability.Multimedia.Media.AVRecorder

NameTypeRead-OnlyOptionalDescription
audioBitratenumberNoYesAudio encoding bit rate. This parameter is mandatory for audio recording.
Supported bit rate ranges:
- Range [32000, 500000] for the AAC encoding format.
- 64000 for the G.711 μ-law encoding format.
- Range [8000, 16000, 32000, 40000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000] for the MP3 encoding format.
When the MP3 encoding format is used, the mapping between the sample rate and bit rate is as follows:
- When the sample rate is lower than 16 kHZ, the bit rate range is [8000 - 64000].
- When the sample rate ranges from 16 kHz to 32 kHz, the bit rate range is [8000, 160000].
- When the sample rate is greater than 32 kHz, the bit rate range is [32000, 320000].
- Range [4750, 5150, 5900, 6700, 7400, 7950, 10200, 12200] for the AMR-NB encoding format.
- Range [6600, 8850, 12650, 14250, 15850, 18250, 19850, 23050, 23850] for the AMR-WB encoding format.
Atomic service API: This API can be used in atomic services since API version 12.
audioChannelsnumberNoYesAudio channel count. This parameter is mandatory for audio recording.
- Range [1, 2] for the AAC encoding format.
- 1 for the G.711 μ-law encoding format.
- Range [1, 2] for the MP3 encoding format.
- 1 for the AMR-NB and AMR-WB encoding formats.
Atomic service API: This API can be used in atomic services since API version 12.
audioCodecCodecMimeTypeNoYesAudio encoding format. This parameter is mandatory for audio recording.
Currently, AUDIO_AAC, AUDIO_MP3, AUDIO_G711MU, AUDIO_AMR_NB, and AUDIO_AMR_WB are supported.
Atomic service API: This API can be used in atomic services since API version 12.
aacProfile22+AacProfileNoYesExtended audio encoding format. The default value is AAC_LC.
Currently, the following formats are supported: AAC_LC, AAC_HE, and AAC_HE_V2.
Atomic service API: This API can be used in atomic services since API version 22.
audioSampleRatenumberNoYesAudio sample rate. This parameter is mandatory for audio recording.
Supported sample rate ranges:
- Range [8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000] for the AAC encoding format.
- 8000 for the G.711 μ-law encoding format.
- Range [8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000] for the MP3 encoding format.
- 8000 for the AMR-NB encoding format.
- 16000 for the AMR-WB encoding format.
Variable bit rate. The bit rate is for reference only.
Atomic service API: This API can be used in atomic services since API version 12.
fileFormatContainerFormatTypeNoNoContainer format of a file. This parameter is mandatory. Currently, the MP4, M4A, MP3, WAV, AMR, and AAC container formats are supported. The default container format for AAC audio is ADTS frame format. The AUDIO_MP3 encoding format is not supported within the MP4 container format.
Atomic service API: This API can be used in atomic services since API version 12.
videoBitratenumberNoYesVideo encoding bit rate. This parameter is mandatory for video recording. The value range is [10000, 100000000].
videoCodecCodecMimeTypeNoYesVideo encoding format. This parameter is mandatory for video recording. Currently, VIDEO_AVC and VIDEO_HEVC are supported.
videoFrameWidthnumberNoYesWidth of a video frame. This parameter is mandatory for video recording. The value range is [176, 4096].
videoFrameHeightnumberNoYesHeight of a video frame. This parameter is mandatory for video recording. The value range is [144, 4096].
videoFrameRatenumberNoYesVideo frame rate. This parameter is mandatory for video recording. The recommended value range is [1, 60].
isHdr11+booleanNoYesHDR encoding. This parameter is optional for video recording. The default value is false, and there is no requirement on the encoding format. When isHdr is set to true, the encoding format must be video/hevc.
enableTemporalScale12+booleanNoYesWhether temporal layered encoding is supported. This parameter is optional for video recording. The default value is false. If this parameter is set to true, some frames in the video output streams can be skipped without being encoded.
enableBFrame20+booleanNoYesWhether B-frame encoding is enabled for video recording. true if enabled (valid only when the video encoding format is H.265 and the device hardware supports B-frame encoding), false otherwise.
This parameter is optional in video recording scenarios. The default value is false.

Audio Parameters

The following table lists the audio parameters. For details about each parameter, see the field description below.

Encoding FormatContainer FormatSample RateBit RateAudio Channel Count
AUDIO_AACMP4, M4A[8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000][32000-500000][1-2]
AUDIO_MP3MP3[8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000]
- When the sample rate is lower than 16000, the bit rate range is [8000, 16000, 32000, 40000, 48000, 56000, 64000].
- When the sample rate ranges from 16000 to 32000, the bit rate range is [8000, 16000, 32000, 40000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 160000].
- When the sample rate is greater than 32000, the bit rate range is [32000, 40000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000].
[1-2]
AUDIO_G711MUWAV[8000][64000][1]
AUDIO_AMR_NB18+AMR[8000][4750, 5150, 5900, 6700, 7400, 7950, 10200, 12200][1]
AUDIO_AMR_WB18+AMR[16000][6600, 8850, 12650, 14250, 15850, 18250, 19850, 23050, 23850][1]

Location

Describes the geographical location of the recorded video.

System capability: SystemCapability.Multimedia.Media.Core

NameTypeRead-OnlyOptionalDescription
latitudenumberNoNoLatitude of the geographical location. The value range is [-90, 90].
longitudenumberNoNoLongitude of the geographical location. The value range is [-180, 180].

EncoderInfo11+

Describes the information about an encoder.

System capability: SystemCapability.Multimedia.Media.AVRecorder

NameTypeRead-OnlyOptionalDescription
mimeTypeCodecMimeTypeNoNoMIME type of the encoder.
typestringNoNoEncoder type. The value audio means an audio encoder, and video means a video encoder.
bitRateRangeNoYesBit rate range of the encoder, with the minimum and maximum bit rates specified.
frameRateRangeNoYesVideo frame rate range, with the minimum and maximum frame rates specified. This parameter is available only for video encoders.
widthRangeNoYesVideo frame width range, with the minimum and maximum widths specified. This parameter is available only for video encoders.
heightRangeNoYesVideo frame height range, with the minimum and maximum heights specified. This parameter is available only for video encoders.
channelsRangeNoYesAudio channel count for the audio capturer, with the minimum and maximum numbers of audio channels specified. This parameter is available only for audio encoders.
sampleRateArray<number>NoYesAudio sample rate, including all available audio sample rates. The value depends on the encoder type, and this parameter is available only for audio encoders.

Range11+

Describes a range.

System capability: SystemCapability.Multimedia.Media.AVRecorder

NameTypeRead-OnlyOptionalDescription
minnumberNoNoMinimum value.
maxnumberNoNoMaximum value.

AVTranscoderConfig12+

Describes the video transcoding parameters.

System capability: SystemCapability.Multimedia.Media.AVTranscoder

NameTypeRead-OnlyOptionalDescription
audioBitratenumberNoYesBit rate of the output audio, in bit/s. The value range is [1, 500000]. The default value is 48 kbit/s.
Atomic service API: This API can be used in atomic services since API version 22.
audioCodecCodecMimeTypeNoYesEncoding format of the output audio. Currently, only AAC is supported. The default value is AAC.
Atomic service API: This API can be used in atomic services since API version 22.
fileFormatContainerFormatTypeNoNoContainer format of the output video file. Currently, only MP4 is supported.
Atomic service API: This API can be used in atomic services since API version 22.
videoBitratenumberNoYesBit rate of the output video, in bit/s. The default bit rate depends on the resolution of the output video. The default bit rate is 1 Mbit/s for the resolution in the range [240p, 480P], 2 Mbit/s for the range (480P, 720P], 4 Mbit/s for the range (720P, 1080P], and 8 Mbit/s for 1080p or higher.
Atomic service API: This API can be used in atomic services since API version 22.
videoCodecCodecMimeTypeNoYesEncoding format of the output video. Currently, only AVC and HEVC are supported. If the source video is in HEVC format, the default value is HEVC. Otherwise, the default value is AVC.
Atomic service API: This API can be used in atomic services since API version 22.
videoFrameWidthnumberNoYesWidth of the output video frame, in px. The value range is [240, 3840]. The default value is the width of the source video frame.
Atomic service API: This API can be used in atomic services since API version 22.
videoFrameHeightnumberNoYesHeight of the output video frame, in px. The value range is [240, 2160]. The default value is the height of the source video frame.
Atomic service API: This API can be used in atomic services since API version 22.
enableBFrame20+booleanNoYesWhether B-frame encoding is enabled for transcoding. true if enabled, false otherwise.
For details about the restrictions on B-frame video encoding, see Constraints in B-Frame Video Encoding. If the current environment does not meet these constraints, B-frames will be skipped, and encoding will proceed as if B-frame video encoding were not enabled.
Atomic service API: This API can be used in atomic services since API version 22.

AVMetadata11+

Defines the audio and video metadata.

System capability: SystemCapability.Multimedia.Media.AVMetadataExtractor

NameTypeRead-OnlyOptionalDescription
albumstringNoYesTitle of the album. This property cannot be set for the AVRecorder.
albumArtiststringNoYesArtist of the album. This property cannot be set for the AVRecorder.
artiststringNoYesArtist of the media asset. This property cannot be set for the AVRecorder.
authorstringNoYesAuthor of the media asset. This property cannot be set for the AVRecorder.
dateTimestringNoYesTime when the media asset is created. This property cannot be set for the AVRecorder.
dateTimeFormatstringNoYesTime when the media asset is created. The value is in the YYYY-MM-DD HH:mm:ss format. This property cannot be set for the AVRecorder.
composerstringNoYesComposer of the media asset. This property cannot be set for the AVRecorder.
durationstringNoYesDuration of the media asset. This property cannot be set for the AVRecorder.
genrestringNoYesType or genre of the media asset.
hasAudiostringNoYesWhether the media asset contains audio. This property cannot be set for the AVRecorder.
hasVideostringNoYesWhether the media asset contains a video. This property cannot be set for the AVRecorder.
mimeTypestringNoYesMIME type of the media asset. This property cannot be set for the AVRecorder.
trackCountstringNoYesNumber of tracks of the media asset. This property cannot be set for the AVRecorder.
sampleRatestringNoYesAudio sample rate, in Hz. This property cannot be set for the AVRecorder.
titlestringNoYesTitle of the media asset. This parameter is read-only in the current version. This property cannot be set for the AVRecorder.
description23+stringNoYesDescription of a media resource. This parameter is read-only in the current version. This property cannot be set for the AVRecorder.
videoHeightstringNoYesVideo height, in px. This property cannot be set for the AVRecorder.
videoWidthstringNoYesVideo width, in px. This property cannot be set for the AVRecorder.
videoOrientationstringNoYesVideo rotation direction, in degrees.
hdrType12+HdrTypeNoYesHDR type of the media asset. This property cannot be set for the AVRecorder.
location12+LocationNoYesGeographical location of the media asset.
customInfo12+Record<string, string>NoYesCustom key-value mappings obtained from moov.meta.list.
tracks20+Array<MediaDescription>NoYesTrack information of the media asset. This property cannot be set for the AVRecorder.
encoderstringNoYesIdentifier of the software, hardware, and settings used for encoding. This property cannot be set for the AVRecorder.
Since: 26.0.0
Model restriction: This API can be used only in the stage model.

MediaDescriptionKey8+ Values Supported by AVMetadata.tracks

The following table lists the values of MediaDescriptionKey supported by AVMetadata.tracks.

NameValueApplicable Track Type
MD_KEY_TRACK_INDEX'track_index'All
MD_KEY_TRACK_TYPE'track_type'All
MD_KEY_CODEC_MIME'codec_mime'Audio and video
MD_KEY_WIDTH'width'Video
MD_KEY_HEIGHT'height'Video
MD_KEY_FRAME_RATE'frame_rate'Video
MD_KEY_AUD_CHANNEL_COUNT'channel_count'Audio
MD_KEY_AUD_SAMPLE_RATE'sample_rate'Audio
MD_KEY_HDR_TYPE12+'hdr_type'Video
MD_KEY_ORIGINAL_WIDTH21+'original_width'Video
MD_KEY_ORIGINAL_HEIGHT21+'original_height'Video
MD_KEY_BITRATE'bitrate'Audio and video (supported since API version 21)
MD_KEY_AUD_SAMPLE_DEPTH12+'sample_depth'Audio (supported since API version 21)

PixelMapParams12+

Defines the format parameters of the video thumbnail to be obtained.

System capability: SystemCapability.Multimedia.Media.AVImageGenerator

NameTypeRead-OnlyOptionalDescription
widthnumberNoYesWidth of the thumbnail, in pixels.
The value must be greater than 0 and less than or equal to the width of the original video. Otherwise, the returned thumbnail will not be scaled.
heightnumberNoYesHeight of the thumbnail, in pixels.
The value must be greater than 0 and less than or equal to the height of the original video. Otherwise, the returned thumbnail will not be scaled.

OutputSize20+

Describes the output size of the video thumbnail fetched.

System capability: SystemCapability.Multimedia.Media.AVImageGenerator

NameTypeRead-OnlyOptionalDescription
widthnumberNoYesWidth of the thumbnail, in pixels.
- If this parameter is set to a value less than 0, the width will be the original video width.
- If the value is 0 or is not assigned, the scaling ratio is the same as the height ratio.
- If neither width nor height is assigned, the output is the width and height of the original video frame.
heightnumberNoYesHeight of the thumbnail, in pixels.
- If this parameter is set to a value less than 0, the height will be the original video height.
- If the value is 0 or is not assigned, the scaling ratio is the same as the width ratio.
- If neither width nor height is assigned, the output is the width and height of the original video frame.

FrameInfo23+

Describes the return value of the operation for obtaining video thumbnails in batches, including the time point for requesting frame extraction, actual time point for frame extraction, format of thumbnails output from the video, and result of obtaining a single thumbnail.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Multimedia.Media.AVMetadataExtractor

NameTypeRead-OnlyOptionalDescription
requestedTimeUsnumberNoNoTime point for requesting frame extraction.
actualTimeUsnumberNoYesActual time point for frame extraction.
imageimage.PixelMapNoYesFormat of the thumbnail output from the video.
resultFetchResultNoNoResult of the task for obtaining a single thumbnail. For example, the task is successful, failed, or canceled.

MediaStream19+

Defines the media stream data information.

Atomic service API: This API can be used in atomic services since API version 19.

System capability: SystemCapability.Multimedia.Media.Core

NameTypeRead-OnlyOptionalDescription
urlstringNoNoURL of the media resource. Only HTTP and HTTPS are supported.
widthnumberNoNoVideo width of the media resource. If the video width is unknown, set it to 0. In this case, PlaybackStrategy cannot be used for optimal matching.
heightnumberNoNoVideo height of the media resource. If the video width is unknown, set it to 0. In this case, PlaybackStrategy cannot be used for optimal matching.
bitratenumberNoNoBit rate of media resources, in bit/s.

MediaSourceLoader18+

Defines a media data loader, which needs to be implemented by applications.

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.Multimedia.Media.Core

NameTypeRead-OnlyOptionalDescription
openSourceOpenCallbackNoNoCallback function implemented by applications to handle resource open requests.
readSourceReadCallbackNoNoCallback function implemented by applications to handle resource read requests.
closeSourceCloseCallbackNoNoCallback function implemented by applications to handle resource close requests.

Example

import { HashMap } from '@kit.ArkTS';
import { media } from '@kit.MediaKit';

let headers: Record<string, string> = {"User-Agent" : "User-Agent-Value"};
let mediaSource : media.MediaSource = media.createMediaSourceWithUrl("http://xxx",  headers);
let uuid: number = 1;
let requests: HashMap<number, media.MediaSourceLoadingRequest> = new HashMap();
let mediaSourceLoader: media.MediaSourceLoader = {
  open: (request: media.MediaSourceLoadingRequest) => {
    console.info(`Opening resource: ${request.url}`);
    // Open the resource and return a unique handle, ensuring the mapping between the UUID and request.
    uuid += 1;
    requests.set(uuid, request);
    return uuid;
  },
  read: (uuid: number, requestedOffset: number, requestedLength: number) => {
    console.info(`Reading resource with handle ${uuid}, offset: ${requestedOffset}, length: ${requestedLength}`);
    // Check whether the UUID is valid and store the read request. Avoid blocking the request while pushing data and header information.
  },
  close: (uuid: number) => {
    console.info(`Closing resource with handle ${uuid}`);
    // Clear resources related to the current UUID.
    requests.remove(uuid);
  }
};

mediaSource.setMediaResourceLoaderDelegate(mediaSourceLoader);
let playStrategy : media.PlaybackStrategy = {
  preferredBufferDuration: 20,
};

async function setupPlayer() {
  let player = await media.createAVPlayer();
  player.setMediaSource(mediaSource, playStrategy);
}

PlaybackStrategy12+

Describes the playback strategy.

System capability: SystemCapability.Multimedia.Media.Core

NameTypeRead-OnlyOptionalDescription
preferredWidthnumberNoYesPreferred width, in px. The value is an integer greater than 0, for example, 1080.
Atomic service API: This API can be used in atomic services since API version 12.
preferredHeightnumberNoYesPreferred height, in px. The value is an integer greater than 0, for example, 1920.
Atomic service API: This API can be used in atomic services since API version 12.
preferredBufferDurationnumberNoYesPreferred buffer duration, in seconds. The value range is [1, 20].
For details, see Minimizing Stuttering in Online Video Playback.
Atomic service API: This API can be used in atomic services since API version 12.
preferredHdrbooleanNoYesWhether HDR is preferred. true if preferred, false otherwise. The default value is false.
Atomic service API: This API can be used in atomic services since API version 12.
enableSuperResolution18+booleanNoYesWhether to enable super resolution. true to enable, false otherwise. The default value is false.
If super resolution is disabled, super resolution APIs cannot be called. If super resolution is enabled, the default target resolution is 1920 × 1080, in px.
Atomic service API: This API can be used in atomic services since API version 18.
showFirstFrameOnPrepare17+booleanNoYesWhether to show the first frame after prepare is called. true to show, false otherwise. The default value is false.
Atomic service API: This API can be used in atomic services since API version 17.
mutedMediaTypeMediaTypeNoYesType of the media to mute.
From API version 12 to 19, only MediaType.MEDIA_TYPE_AUD can be set. Starting from API version 20, MediaType.MEDIA_TYPE_VID is added.
preferredAudioLanguage13+stringNoYesPreferred audio track language. Set this parameter based on service requirements in DASH scenarios. In non-DASH scenarios, this parameter is not supported, and you are advised to retain the default value.
Atomic service API: This API can be used in atomic services since API version 13.
preferredSubtitleLanguage13+stringNoYesPreferred subtitle language. Set this parameter based on service requirements in DASH scenarios. In non-DASH scenarios, this parameter is not supported, and you are advised to retain the default value.
Atomic service API: This API can be used in atomic services since API version 13.
preferredBufferDurationForPlaying18+numberNoYesPreferred buffer duration for playback, in seconds. The playback starts once the buffering time exceeds this value. The value range is [0, 20].
Atomic service API: This API can be used in atomic services since API version 18.
thresholdForAutoQuickPlay18+numberNoYesThread for starting smart frame catching, in seconds. The value must be greater than or equal to 2s and greater than preferredBufferDurationForPlaying. The default value is 5s.
You can use the playback strategy to maintain the real-time quality of live streams by adjusting the smart frame-catch threshold. For FLV live streams, you can set this parameter based on service requirements. This parameter is not supported for non-FLV live streams yet. Fluctuations in network conditions can cause the player to build up a lot of data over time. The player periodically checks the gap between the current playback time and the timestamp of the latest frame in the cache. If this gap is too big, the player starts catching up at 1.2x speed. The on('speedDone') event will call back a specific value of 100, indicating that the smart frame catching feature is enabled successfully. Once the gap falls below preferredBufferDurationForPlaying, the player stops catching up and resumes the normal playback speed.
Atomic service API: This API can be used in atomic services since API version 18.
keepDecodingOnMute20+booleanNoYesWhether the decoder continues to run when the video media is muted, which helps in quickly opening the media. Currently, this feature is available only for videos. The default value is false, indicating that the decoder stops running when the media is muted, reducing power consumption.
Atomic service API: This API can be used in atomic services since API version 20.

AVScreenCaptureStrategy20+

Describes the screen capture strategy.

System capability: SystemCapability.Multimedia.Media.AVScreenCapture

NameTypeRead-OnlyOptionalDescription
keepCaptureDuringCallbooleanNoYesWhether to keep screen capture during a cellular call. The value true means to keep screen capture during a cellular call, and false means the opposite. The default value is false.
enableBFramebooleanNoYesWhether to enable B-frame encoding for screen capture. true to enable, false otherwise. The default value is false.
For details about the restrictions on B-frame video encoding, see Constraints in B-Frame Video Encoding. If the current environment does not meet the restrictions, B-frames will be skipped during screen capture, and no error will be returned.
privacyMaskMode23+numberNoYesMask mode for privacy windows during screen capture.
- 0: Full-screen mask mode for privacy windows. The default value is 0.
- 1: Window mask mode for privacy windows.
- If this parameter is set to other values, an error is returned.
Model restriction: This API can be used only in the stage model.
enablePausebooleanNoYesWhether screen capture can be paused.
true: yes; false: no. The default value is false.
Since: 26.0.0
Model restriction: This API can be used only in the stage model.

AVScreenCaptureRecordConfig12+

Defines the screen capture parameters.

System capability: SystemCapability.Multimedia.Media.AVScreenCapture

NameTypeRead-OnlyOptionalDescription
fdnumberNoNoFD of the file output.
frameWidthnumberNoYesWidth of the screen recording video, in pixels.
The default screen width varies depending on the screen.
frameHeightnumberNoYesHeight of the screen recording video, in pixels.
The default screen height varies depending on the screen.
videoBitratenumberNoYesBit rate of the screen recording video.
The default value is 10000000.
audioSampleRatenumberNoYesAudio sampling rate of the screen recording.
This value is used for both the system sound and microphone. Only 48000 (default) and 16000 are supported.
audioChannelCountnumberNoYesAudio channel count. This value is used for both internal capture and external capture (using microphones). Only 1 and 2 (default) are supported.
audioBitratenumberNoYesAudio bit rate. This value is used for both internal capture and external capture (using microphones). The default value is 96000.
presetAVScreenCaptureRecordPresetNoYesEncoding and container format used. The default value is SCREEN_RECORD_PRESET_H264_AAC_MP4.
displayId15+numberNoYesID of the display used for screen capture. By default, the main screen is captured.
fillMode18+AVScreenCaptureFillModeNoYesVideo fill mode during screen capture.
strategy20+AVScreenCaptureStrategyNoYesScreen capture strategy.

AVMetricsEvent23+

Describes the information about a metric event.

System capability: SystemCapability.Multimedia.Media.AVPlayer

NameTypeRead-OnlyOptionalDescription
eventAVMetricsEventTypeNoNoType of the metric event.
Model restriction: This API can be used only in the stage model.
timeStampnumberNoNoSystem time when an event occurs.
playbackPositionnumberNoNoPlayback position when an event occurs.
detailsRecord<string, Object>NoNoDetailed information about an event. The information contained in an event varies according to the event type.
The information includes the stalling duration (duration: number) and the media type (media: MediaType) of the stalling.
Model restriction: This API can be used only in the stage model.

VideoSize24+

Describes the video size.

System capability: SystemCapability.Multimedia.Media.Core

NameTypeRead-OnlyOptionalDescription
widthnumberNoYesVideo resolution width.
The value must be a positive integer (greater than 0).
heightnumberNoYesVideo resolution height.
The value must be a positive integer (greater than 0).

TrackSelectionFilter24+

Describes the track selection filter.

System capability: SystemCapability.Multimedia.Media.Core

NameTypeRead-OnlyOptionalDescription
maxVideoBitratenumberNoYesMaximum bit rate of the video, in bit/s.
The value must be a positive integer (greater than 0).
minVideoBitratenumberNoYesMinimum bit rate of the video, in bit/s.
The value must be a positive integer (greater than 0).
maxVideoFrameRatenumberNoYesMaximum frame rate of the video, in Hz.
The value must be a positive integer (greater than 0).
minVideoFrameRatenumberNoYesMinimum frame rate of the video, in Hz.
The value must be a positive integer (greater than 0).
maxVideoResolutionVideoSizeNoYesMaximum resolution of the video.
minVideoResolutionVideoSizeNoYesMinimum resolution of the video.
preferredVideoMimeTypesArray<string>NoYesPreferred MIME types of the video track, sorted by priority. An empty value indicates that any type is accepted.
maxAudioBitratenumberNoYesMaximum bit rate of the audio, in bit/s.
The value must be a positive integer (greater than 0).
minAudioBitratenumberNoYesMinimum bit rate of the audio, in bit/s.
The value must be a positive integer (greater than 0).
maxAudioChannelsnumberNoYesMaximum number of audio channels.
The value must be a positive integer (greater than 0).
preferredAudioMimeTypesArray<string>NoYesPreferred MIME type of the audio track, sorted by priority. An empty value indicates that any type is acceptable.
preferredAudioLanguagesArray<string>NoYesPreferred languages of the audio track, sorted by priority. The value is a language tag that complies with the IETF BCP 47 criterion. An empty value indicates that any language is accepted.
preferredSubtitleLanguagesArray<string>NoYesPreferred languages of the subtitle track, sorted by priority. The value is a language tag that complies with the IETF BCP 47 criterion. An empty value indicates that any language is accepted.

AudioRecorderConfig(deprecated)

NOTE This API is supported since API version 6 and deprecated since API version 9. You are advised to use AVRecorderConfig instead.

Describes audio recording configurations.

System capability: SystemCapability.Multimedia.Media.AudioRecorder

NameTypeRead-OnlyOptionalDescription
audioEncoderAudioEncoderNoYesAudio encoding format. The default value is AAC_LC.
Note: This parameter is supported since API version 6 and deprecated since API version 8. You are advised to use audioEncoderMime instead.
audioEncodeBitRatenumberNoYesAudio encoding bit rate. The default value is 48000.
Note: This parameter is supported since API version 6 and deprecated since API version 9. You are advised to use audioBitrate in AVRecorderProfile instead.
audioSampleRatenumberNoYesAudio sample rate. The default value is 48000.
Variable bit rate. The bit rate is for reference only.
Note: This parameter is supported since API version 6 and deprecated since API version 9. You are advised to use audioSampleRate in AVRecorderProfile instead.
numberOfChannelsnumberNoYesAudio channel count. The default value is 2.
Note: This parameter is supported since API version 6 and deprecated since API version 9. You are advised to use audioChannels in AVRecorderProfile instead.
formatAudioOutputFormatNoYesAudio output format. The default value is MPEG_4.
Note: This parameter is supported since API version 6 and deprecated since API version 8. You are advised to use fileFormat instead.
locationLocationNoYesGeographical location of the recorded audio.
Note: This parameter is supported since API version 6 and deprecated since API version 9. You are advised to use location in AVMetadata instead.
uristringNoNoAudio output URI. Supported: fd://xx (fd number)

The file must be created by the caller and granted with proper permissions.
Note: This parameter is supported since API version 6 and deprecated since API version 9. You are advised to use url in AVRecorderConfig instead.
audioEncoderMime8+CodecMimeTypeNoYesContainer encoding format.
Note: This parameter is supported since API version 8 and deprecated since API version 9. You are advised to use audioCodec in AVRecorderProfile instead.
fileFormat8+ContainerFormatTypeNoYesAudio encoding format.
Note: This parameter is supported since API version 8 and deprecated since API version 9. You are advised to use fileFormat in AVRecorderProfile instead.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-avrecorder-oh-avrecorder-range

openharmony 鸿蒙 errorcode-media

openharmony 鸿蒙 capi-avplayer

openharmony 鸿蒙 capi-avplayer-base-h

openharmony 鸿蒙 capi-avimage-generator-h

openharmony 鸿蒙 capi-avscreencapture-oh-rect

openharmony 鸿蒙 capi-videoprocessing-videoprocessing-callback

openharmony 鸿蒙 capi-avsinkbase

openharmony 鸿蒙 capi-avmetadataextractor

openharmony 鸿蒙 capi-avscreencapture-oh-multidisplaycapability

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/4gwZLKCq