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

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

相关推荐
极客先躯2 小时前
高级java每日一道面试题-2025年3月05日-微服务篇[Eureka篇]-Eureka在微服务架构中的角色?
java·微服务·架构·服务注册·健康检查·架构服务发现
VincentStory2 小时前
分享一个项目中遇到的一个算法题
android·算法
北漂老男孩3 小时前
IntelliJ IDEA 调试技巧指南
java·ide·intellij-idea
八股文领域大手子4 小时前
Leetcode32 最长有效括号深度解析
java·数据库·redis·sql·mysql
上官美丽4 小时前
Springboot中的@ConditionalOnBean注解:使用指南与最佳实践
java·spring boot·mybatis
Another Iso4 小时前
Windows安装Apache Maven 3.9.9
java·maven
鹏神丶明月天4 小时前
mybatis_plus的乐观锁
java·开发语言·数据库
fantasy_44 小时前
Java数据类型 Arrays VS ArraysList VS LikedList 解析
java
IT__learning4 小时前
Java通过Apache POI操作Excel
java·apache·excel
yechaoa4 小时前
【揭秘大厂】技术专项落地全流程
android·前端·后端