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

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

相关推荐
武子康4 分钟前
大数据-230 离线数仓 - ODS层的构建 Hive处理 UDF 与 SerDe 处理 与 当前总结
java·大数据·数据仓库·hive·hadoop·sql·hdfs
武子康6 分钟前
大数据-231 离线数仓 - DWS 层、ADS 层的创建 Hive 执行脚本
java·大数据·数据仓库·hive·hadoop·mysql
苏-言12 分钟前
Spring IOC实战指南:从零到一的构建过程
java·数据库·spring
界面开发小八哥19 分钟前
更高效的Java 23开发,IntelliJ IDEA助力全面升级
java·开发语言·ide·intellij-idea·开发工具
草莓base33 分钟前
【手写一个spring】spring源码的简单实现--容器启动
java·后端·spring
Dnelic-37 分钟前
【单元测试】【Android】JUnit 4 和 JUnit 5 的差异记录
android·junit·单元测试·android studio·自学笔记
Allen Bright1 小时前
maven概述
java·maven
编程重生之路1 小时前
Springboot启动异常 错误: 找不到或无法加载主类 xxx.Application异常
java·spring boot·后端
薯条不要番茄酱1 小时前
数据结构-8.Java. 七大排序算法(中篇)
java·开发语言·数据结构·后端·算法·排序算法·intellij-idea
runing_an_min1 小时前
ffmpeg视频滤镜:替换部分帧-freezeframes
ffmpeg·音视频·freezeframes