human: 如何处理七牛云的实时音视频QNCameraVideoTrack

gpt: [实时音视频](https://developer.qiniu.com/rtc) > API 文档 > Uniapp >QNCameraVideoTrack

#  QNCameraVideoTrack

最近更新时间: 2023-12-11 16:00:40

Hierarchy

  * [QNLocalVideoTrack](https://developer.qiniu.com/rtc/11433/UniappQNCameraVideoTrack/11401/UniappQNLocalVideoTrack)
    * QNCameraVideoTrack 

Index

Property

  * getMuted
  * kind
  * tag
  * trackID
  * userID

Method

  * clearWaterMark
  * destroy
  * encodeMirrorFrontFacing
  * encodeMirrorRearFacing
  * getMaxExposureCompensation
  * getMinExposureCompensation
  * getTag
  * getTrackID
  * getUserID
  * getVideoOrientation
  * getZooms
  * isAudio
  * isMuted
  * isVideo
  * manualFocus
  * off
  * on
  * previewMirrorFrontFacing
  * previewMirrorRearFacing
  * pushImage
  * sendSEI
  * setBeauty
  * setExposureCompensation
  * setMuted
  * setPreviewEnabled
  * setSessionPreset
  * setVideoEncoderConfig
  * setVideoOrientation
  * setWaterMark
  * setZoom
  * startCapture
  * stopCapture
  * switchCamera
  * takeVideoSnapshot
  * trimBase64
  * turnLightOff
  * turnLightOn

Property

getMuted

  * getMuted: {}
  * 是否 muted

kind

  * kind: [QNRTCTrackKind](https://developer.qiniu.com/rtc/11433/UniappQNCameraVideoTrack/11395/UniappQNRTCTrackKind)
  * 类型

tag

  * tag: string
  * 自定义 tag

trackID

  * trackID: string
  * trackID

userID

  * userID: string
  * 用户 ID

Method

clearWaterMark

  * clearWaterMark(): void
  * 清空水印配置

Returns void

destroy

  * destroy(): void
  * 销毁本地创建的 Track

Returns void

encodeMirrorFrontFacing

  * encodeMirrorFrontFacing(encodeMirrorFrontFacing: boolean): void
  * 前置摄像头，编码以及预览是否开启镜像

> 默认 NO

Parameters

    * encodeMirrorFrontFacing: boolean 

是否开启镜像

Returns void

encodeMirrorRearFacing

  * encodeMirrorRearFacing(encodeMirrorRearFacing: boolean): void
  * 后置摄像头，编码以及预览是否开启镜像

> 默认 NO

Parameters

    * encodeMirrorRearFacing: boolean 

是否开启镜像

Returns void

getMaxExposureCompensation

  * getMaxExposureCompensation(): number
  * 获取最大曝光度

Returns number

getMinExposureCompensation

  * getMinExposureCompensation(): number
  * 获取最小曝光度

Returns number

getTag

  * getTag(): string
  * 获取 Tag

Returns string

getTrackID

  * getTrackID(): string
  * 获取 TrackID

> 对于本地 Track，当且仅当 Track 发布后才可获取到有效的 TrackID；对于远端 Track，可随时获取到有效的 TrackID

Returns string

getUserID

  * getUserID(): string
  * 获取 UserID

Returns string

getVideoOrientation

  * getVideoOrientation(): [QNAVCaptureVideoOrientation](https://developer.qiniu.com/rtc/11433/UniappQNCameraVideoTrack/11430/UniappQNAVCaptureVideoOrientation)
  * 获取camera 时的采集摄像头的旋转方向

> 只支持ios

Returns
[QNAVCaptureVideoOrientation](https://developer.qiniu.com/rtc/11433/UniappQNCameraVideoTrack/11430/UniappQNAVCaptureVideoOrientation)

getZooms

  * getZooms(): number[]
  * 获取支持的缩放大小列表

> 缩放大小范围为 0.0 - 1.0

Returns number[]

isAudio

  * isAudio(): boolean
  * 是否为音频 Track

Returns boolean

isMuted

  * isMuted(): boolean
  * 是否 muted

Returns boolean

isVideo

  * isVideo(): boolean
  * 是否为视频 Track

Returns boolean

manualFocus

  * manualFocus(x: number, y: number): void
  * 手动聚焦

> 对于前置摄像头，大部分机型并不支持手动对焦，因此，请勿调用该接口，否则会抛异常

Parameters

    * x: number 

焦点 x 轴绝对位置，范围 0 - 1

    * y: number 

焦点 y 轴绝对位置，范围 0 - 1

Returns void

off

  * off(name: event, listener: [QNRTCTrackEvent](https://developer.qiniu.com/rtc/11433/UniappQNCameraVideoTrack/11409/UniappQNRTCTrackEvent)[event]): void
  * 取消监听对应的事件

> 取消监听对应的事件

Parameters

    * name: event 

事件名

    * listener: [QNRTCTrackEvent](https://developer.qiniu.com/rtc/11433/UniappQNCameraVideoTrack/11409/UniappQNRTCTrackEvent)[event] 

事件句柄

Returns void

on

  * on(name: event, listener: [QNRTCTrackEvent](https://developer.qiniu.com/rtc/11433/UniappQNCameraVideoTrack/11409/UniappQNRTCTrackEvent)[event]): void
  * 监听对应的事件

> 支持多次调用同一事件

Parameters

    * name: event 

事件名

    * listener: [QNRTCTrackEvent](https://developer.qiniu.com/rtc/11433/UniappQNCameraVideoTrack/11409/UniappQNRTCTrackEvent)[event] 

事件句柄

Returns void

previewMirrorFrontFacing

  * previewMirrorFrontFacing(previewMirrorFrontFacing: boolean): void
  * 前置摄像头预览是否开启镜像

> 默认 YES

Parameters

    * previewMirrorFrontFacing: boolean 

是否开启镜像

Returns void

previewMirrorRearFacing

  * previewMirrorRearFacing(previewMirrorRearFacing: boolean): void
  * 后置摄像头预览是否开启镜像

> 默认 NO

Parameters

    * previewMirrorRearFacing: boolean 

是否开启镜像

Returns void

pushImage

  * pushImage(image: [QNImage](https://developer.qiniu.com/rtc/11433/UniappQNCameraVideoTrack/11383/UniappQNImage)): void
  * 使用图片替代相机画面

> 如需取消图片替代相机 resourcePath 传空字符串即可

Parameters

    * image: [QNImage](https://developer.qiniu.com/rtc/11433/UniappQNCameraVideoTrack/11383/UniappQNImage)

图片配置

Returns void

sendSEI

  * sendSEI(message: string, repeatCount: number, uuid: string): void
  * 发送 SEI

Parameters

    * message: string 

消息内容

    * repeatCount: number 

重复次数，-1 为每一帧都发送

    * uuid: string 

唯一 ID

Returns void

setBeauty

  * setBeauty(beautySetting: [QNBeautySetting](https://developer.qiniu.com/rtc/11433/UniappQNCameraVideoTrack/11410/UniappQNBeautySetting)): void
  * 设置是否启用美颜

Parameters

    * beautySetting: [QNBeautySetting](https://developer.qiniu.com/rtc/11433/UniappQNCameraVideoTrack/11410/UniappQNBeautySetting)

美颜配置

Returns void

setExposureCompensation

  * setExposureCompensation(value: number): void
  * 设置曝光度

> 只支持安卓

Parameters

    * value: number 

曝光度

Returns void

setMuted

  * setMuted(muted: boolean): void
  * 设置 mute

> 更新当前 Track 的 mute 值

Parameters

    * muted: boolean 

是否 mute

Returns void

setPreviewEnabled

  * setPreviewEnabled(isEnabled: boolean): void
  * 设置是否允许预览

Parameters

    * isEnabled: boolean 

是否允许预览

Returns void

setSessionPreset

  * setSessionPreset(sessionPreset: [QNSessionPresetType](https://developer.qiniu.com/rtc/11433/UniappQNCameraVideoTrack/11418/UniappQNSessionPresetType)): void
  * 设置采集分辨率

> 只支持ios

Parameters

    * sessionPreset: [QNSessionPresetType](https://developer.qiniu.com/rtc/11433/UniappQNCameraVideoTrack/11418/UniappQNSessionPresetType)

分辨率

Returns void

setVideoEncoderConfig

  * setVideoEncoderConfig(preset: [QNVideoEncoderConfig](https://developer.qiniu.com/rtc/11433/UniappQNCameraVideoTrack/12593/UniappQNVideoEncoderConfig)): void
  * 动态修改视频 Track 的编码参数

> 该接口用于在通话过程中动态修改视频的编码参数，若您无需修改，可在创建视频 Track 时通过对应的 TrackConfig 直接指定编码参数
> 建议修改时目标编码分辨率小于采集的分辨率。当目标编码分辨率大于采集分辨率时，SDK
> 会基于采集分辨率裁剪输出一个和目标编码分辨率宽高比相匹配，但小于等于采集分辨率的参数

Parameters

    * preset: [QNVideoEncoderConfig](https://developer.qiniu.com/rtc/11433/UniappQNCameraVideoTrack/12593/UniappQNVideoEncoderConfig)

Returns void

setVideoOrientation

  * setVideoOrientation(videoOrientation: [QNAVCaptureVideoOrientation](https://developer.qiniu.com/rtc/11433/UniappQNCameraVideoTrack/11430/UniappQNAVCaptureVideoOrientation)): void
  * 设置 camera 时的采集摄像头的旋转方向

> 只支持ios，默认 AVCaptureVideoOrientationPortrait

Parameters

    * videoOrientation: [QNAVCaptureVideoOrientation](https://developer.qiniu.com/rtc/11433/UniappQNCameraVideoTrack/11430/UniappQNAVCaptureVideoOrientation)

旋转方向

Returns void

setWaterMark

  * setWaterMark(waterMark: [QNVideoWaterMark](https://developer.qiniu.com/rtc/11433/UniappQNCameraVideoTrack/11392/UniappQNVideoWaterMark)): void
  * 设置水印

Parameters

    * waterMark: [QNVideoWaterMark](https://developer.qiniu.com/rtc/11433/UniappQNCameraVideoTrack/11392/UniappQNVideoWaterMark)

水印配置

Returns void

setZoom

  * setZoom(zoom: number): void
  * 设置缩放大小

Parameters

    * zoom: number 

缩放大小

Returns void

startCapture

  * startCapture(): void
  * 开启摄像头采集

Returns void

stopCapture

  * stopCapture(): void
  * 关闭摄像头采集

Returns void

switchCamera

  * switchCamera(): void
  * 切换相机前后置

Returns void

takeVideoSnapshot

  * takeVideoSnapshot(): Promise<{base64:string,rotate:number}>
  * 截图

Returns Promise<{base64:string,rotate:number}>

trimBase64

  * trimBase64(base64: string): string
  * 去除图片base64字符串中的\r \n 防止图片解析出错

Parameters

    * base64: string 

需要去除\r \n的图片base64字符串

Returns string

turnLightOff

  * turnLightOff(): void
  * 关闭闪光灯

Returns void

turnLightOn

  * turnLightOn(): void
  * 开启闪光灯

Returns void

以上内容是否对您有帮助？