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;
    }`

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

相关推荐
用户3126874877202 分钟前
线程池到底怎么调?从源码看懂 ThreadPoolExecutor 的 7 个参数
java
SQL-First布道者24 分钟前
持久层框架的评价标准:只有一个
java·spring boot·spring·tomcat·mybatis·spring jdbc
孔明click3328 分钟前
Sa-Token v1.46.0 发布 🚀,来看看有没有令你心动的功能!
java·sa-token·开源·springboot·权限认证
人才瘾大31 分钟前
Android录屏内部音频录制完全指南:原理、限制与方案选型
android·音视频
小柯南敲键盘34 分钟前
跨境电商图片翻译与视频字幕翻译工具推荐
python·音视频
m0_587383001 小时前
智慧场馆解决方案实战指南:从系统架构到落地部署全解析
java·spring boot·架构·系统架构
ZC跨境爬虫1 小时前
LeetCode 13. 罗马数字转整数(多解法详解 + Java Python 实现)
java·python·leetcode
网安蟹佬霸1 小时前
Webshell免杀与检测实战:从一句话木马到加密流量
android·安全·web安全·网络安全·黑客·网安·渗透测试·
省长1 小时前
Sa-Token v1.46.0 发布 🚀,来看看有没有令你心动的功能!
java·后端·开源
RockWang.1 小时前
【模型】MiniMax-H3 多模态参考视频生成
音视频