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

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

相关推荐
Monodye15 分钟前
【Java】网络编程:TCP_IP协议详解(IP协议数据报文及如何解决IPv4不够的状况)
java·网络·数据结构·算法·系统架构
一丝晨光21 分钟前
逻辑运算符
java·c++·python·kotlin·c#·c·逻辑运算符
唯创知音28 分钟前
电子烟智能化创新体验:WTK6900P语音交互芯片方案,融合频谱计算、精准语音识别与流畅音频播报
人工智能·单片机·物联网·音视频·智能家居·语音识别
无名指的等待7121 小时前
SpringBoot中使用ElasticSearch
java·spring boot·后端
Tatakai251 小时前
Mybatis Plus分页查询返回total为0问题
java·spring·bug·mybatis
武子康1 小时前
大数据-133 - ClickHouse 基础概述 全面了解
java·大数据·分布式·clickhouse·flink·spark
.生产的驴1 小时前
SpringBoot 消息队列RabbitMQ 消费者确认机制 失败重试机制
java·spring boot·分布式·后端·rabbitmq·java-rabbitmq
Code哈哈笑2 小时前
【C++ 学习】多态的基础和原理(10)
java·c++·学习
chushiyunen2 小时前
redisController工具类
java
消失的旧时光-19432 小时前
kotlin的密封类
android·开发语言·kotlin