Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to obtain the time length of wav by Java

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you "how Java realizes the length of time to obtain wav", the content is simple and easy to understand, and the organization is clear. I hope it can help you solve your doubts. Let Xiaobian lead you to study and learn this article "how Java realizes the length of time to obtain wav".

Maven dependency org jaudiotagger 2.0.1 tool classes import org.jaudiotagger.audio.wav.util.WavInfoReader; import java.io.File;import java.io.IOException;import java.io.RandomAccessFile; /** @Author huyi @Date 2021/9/30 14: 46@Description: Audio Tools */public class AudioWavUtils { public static void getWavInfo(String filePath) throws Exception { File file = new File(filePath); WavInfoReader wavInfoReader = new WavInfoReader(); RandomAccessFile raf = new RandomAccessFile(file, "r"); // wav audio duration long duration = (long) (wavInfoReader.read(raf).getPreciseLength() * 1000); // wav audio sampling rate int sampleRate = toInt(read(raf, 24, 4)); System.out.println("duration -> " + duration + ",sampleRate -> " + sampleRate); raf.close(); } public static int toInt(byte[] b) { return ((b[3]

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report