简体   繁体   English

如何读取和修改amr音频文件数据?

[英]How to read and modify amr audio file data?

How can i extract information like sample rate , bit rate etc from an AMR-NB file . 如何从AMR-NB文件中提取采样率,比特率等信息。 Strictly speaking I want the sample rate or any other data that may alter its pitch or tempo. 严格来说,我想要采样率或任何其他可能改变其音高或节奏的数据。

It was easy for WAV files but here I am constrained with AMR-NB format (J2me Devices) WAV文件很容易,但在这里我受限于AMR-NB格式(J2me设备)

I have searched a lot on google but can't get anything on it ... 我在谷歌上搜索了很多但却无法得到任何东西......

is AMR-NB fixed at 8Khz? AMR-NB固定在8Khz? or it varies with each sample? 或者每个样品都有所不同?

According to the AMR file format at: http://developer.nokia.com/community/wiki/AMR_format AMR files have a 6 byte header, followed by a set of audio frames, each with a 1 byte header. 根据AMR文件格式: http//developer.nokia.com/community/wiki/AMR_format AMR文件有一个6字节的标题,后跟一组音频帧,每个帧都有一个1字节的标题。 Each audio frame is 20 ms long and has and the sample rate is given in the header of each frame. 每个音频帧长20毫秒,并且每帧的标题中都有采样率。 so to read the sample rate for the first frame, you need to read the 7th byte in the file. 因此,要读取第一帧的采样率,您需要读取文件中的第7个字节。 Take the 7th byte and shift it right 3 bits, and mask out the lower 4 bits of the new value. 取第7个字节并将其右移3位,并屏蔽新值的低4位。 In java this is "((value>>3)& 0x0F)" where value is the 1 byte header for the frame. 在java中,这是“((value >> 3)&0x0F)”,其中value是帧的1字节头。 Then check that number against the table below to determine the bitrate for that frame. 然后根据下表检查该数字,以确定该帧的比特率。 then since each frame is 20ms long, you need to multiply the bitrate(they give it as kb/s so multiply that number by 1000 to get the bits per second) by 20 and divide by ((8 bits per byte) * 1000ms per second) = 8000 to get the number of bytes to skip for the next frame header. 那么由于每帧长度为20ms,你需要将比特率(它们以kb / s为单位乘以该数字乘以1000以得到每秒比特数)乘以20并除以((每字节8位)* 1000ms每个帧) second)= 8000以获取下一帧头跳过的字节数。 If you want to modify the contents of the frame simply recopy the frames in sequence to a new file but replace your new frame with an old one. 如果要修改帧的内容,只需将帧按顺序重新复制到新文件,但用旧文件替换新帧。 A temp file is good for this.I've copied the bitrate table form the source page below for reference. 临时文件对此有用。我从下面的源页面复制了比特率表以供参考。

0 - AMR 4.75 - Encodes at 4.75kbit/s 0 - AMR 4.75 - 以4.75kbit / s编码

1 - AMR 5.15 - Encodes at 5.15kbit/s 1 - AMR 5.15 - 以5.15kbit / s的速率编码

2 - AMR 5.9 - Encodes at 5.9kbit/s 2 - AMR 5.9 - 以5.9kbit / s编码

3 - AMR 6.7 - Encodes at 6.7kbit/s 3 - AMR 6.7 - 编码速率为6.7kbit / s

4 - AMR 7.4 - Encodes at 7.4kbit/s 4 - AMR 7.4 - 7.4kbit / s的编码

5 - AMR 7.95 - Encodes at 7.95kbit/s 5 - AMR 7.95 - 编码速率为7.95kbit / s

6 - AMR 10.2 - Encodes at 10.2kbit/s 6 - AMR 10.2 - 以10.2kbit / s的速率编码

7 - AMR 12.2 - Encodes at 12.2kbit/s 7 - AMR 12.2 - 12.2kbit / s的编码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM