android音频录音,(二)MediaRecorder 配置参数简介

1.MediaRecorder 参数定义文件路径:

frameworks/base/media/java/android/media/MediaRecorder.java

2:各参数类型:

音频源类型定音:
/** @hide */
@IntDef({
AudioSource.DEFAULT,
AudioSource.MIC,
AudioSource.VOICE_UPLINK,
AudioSource.VOICE_DOWNLINK,
AudioSource.VOICE_CALL,
AudioSource.CAMCORDER,
AudioSource.VOICE_RECOGNITION,
AudioSource.VOICE_COMMUNICATION,
AudioSource.UNPROCESSED,
AudioSource.VOICE_PERFORMANCE,
})

输出文件格式:
/**
`

  • Defines the output format. These constants are used with
  • {@link MediaRecorder#setOutputFormat(int)}.
    /
    public final class OutputFormat {
    /
    Do not change these values without updating their counterparts
  • in include/media/mediarecorder.h!
    /
    private OutputFormat() {}
    public static final int DEFAULT = 0;
    /
    * 3GPP media file format*/
    public static final int THREE_GPP = 1;
    /** MPEG4 media file format*/
    public static final int MPEG_4 = 2;`

/** The following formats are audio only .aac or .amr formats */

/**
`

  • AMR NB file format
  • @deprecated Deprecated in favor of MediaRecorder.OutputFormat.AMR_NB
    */
    public static final int RAW_AMR = 3;`

/** AMR NB file format */
public static final int AMR_NB = 3;

/** AMR WB file format */
public static final int AMR_WB = 4;

/** @hide AAC ADIF file format */
public static final int AAC_ADIF = 5;

/** AAC ADTS file format */
public static final int AAC_ADTS = 6;

/** @hide Stream over a socket, limited to a single stream */
public static final int OUTPUT_FORMAT_RTP_AVP = 7;

/** H.264/AAC data encapsulated in MPEG2/TS */
public static final int MPEG_2_TS = 8;

/** VP8/VORBIS data in a WEBM container */
public static final int WEBM = 9;

/** @hide HEIC data in a HEIF container */
public static final int HEIF = 10;
/** Opus data in a Ogg container */
public static final int OGG = 11;
};

音频编码器类型:
/**
`

  • Defines the audio encoding. These constants are used with
  • {@link MediaRecorder#setAudioEncoder(int)}.
    /
    public final class AudioEncoder {
    /
    Do not change these values without updating their counterparts
  • in include/media/mediarecorder.h!
    /
    private AudioEncoder() {}
    public static final int DEFAULT = 0;
    /
    * AMR (Narrowband) audio codec /
    public static final int AMR_NB = 1;
    /
    * AMR (Wideband) audio codec /
    public static final int AMR_WB = 2;
    /
    * AAC Low Complexity (AAC-LC) audio codec /
    public static final int AAC = 3;
    /
    * High Efficiency AAC (HE-AAC) audio codec /
    public static final int HE_AAC = 4;
    /
    * Enhanced Low Delay AAC (AAC-ELD) audio codec /
    public static final int AAC_ELD = 5;
    /
    * Ogg Vorbis audio codec (Support is optional) /
    public static final int VORBIS = 6;
    /
    * Opus audio codec */
    public static final int OPUS = 7;
    }`

可以依据自己定制需求,在配置录音设备资源,输出文件格式,以及编码格式,按照如上模式进行调整与更改。

相关推荐
Black蜡笔小新22 分钟前
WebRTC嵌入式视频通话SDK:EasyRTC从免插件到轻量级带来的音视频通话技术
音视频·webrtc·sdk·rtc·webp2p
EasyNVR25 分钟前
EasyRTC:开启智能硬件与全平台互动新时代
网络·音视频·webrtc·p2p·智能硬件·视频监控
EasyGBS25 分钟前
从开发到部署:EasyRTC嵌入式视频通话SDK如何简化实时音视频通信的集成与应用
音视频·webrtc·实时音视频·视频监控
敲代码的小王!1 小时前
MD5加密算法和BCrypt密码加密算法
java·算法·安全
罗政6 小时前
冒险岛079 V8 整合版源码搭建教程+IDEA启动
java·ide·intellij-idea
架构默片7 小时前
【JAVA工程师从0开始学AI】,第五步:Python类的“七十二变“——当Java的铠甲遇见Python的液态金属
java·开发语言·python
不只会拍照的程序猿8 小时前
从插入排序到希尔排序
java·开发语言·数据结构·算法·排序算法
我荔枝呢!8 小时前
Java中的hashCode和equals方法之间有什么联系
java·开发语言·equals·hashcode
望未来无悔9 小时前
系统学习算法:专题十一 floodfill算法
java·算法
黑客老李9 小时前
新手小白如何挖掘cnvd通用漏洞之存储xss漏洞(利用xss钓鱼)
java·运维·服务器·前端·xss