当前位置: 首页 > news >正文

律师网站 扁平化网站自然排名优化

律师网站 扁平化,网站自然排名优化,家做网站,星辰博客wordpress1.背景 最近对接了一款智能手表,手环,可以应用与老人与儿童监控,环卫工人监控,农场畜牧业监控,宠物监控等,其中用到了音频传输,通过平台下发语音包,发送远程命令录制当前设备音频并…

1.背景

最近对接了一款智能手表,手环,可以应用与老人与儿童监控,环卫工人监控,农场畜牧业监控,宠物监控等,其中用到了音频传输,通过平台下发语音包,发送远程命令录制当前设备音频并将音频分包传输到服务器上生成音频文件等。其中关于音频的一些简单操作封装成了工具包。

2.音频工具包

引入jaudiotagger,用来获取MP3格式的音频时长。

        <dependency><groupId>org</groupId><artifactId>jaudiotagger</artifactId><version>2.0.1</version></dependency>

工具包代码:AudioUtils
 

package com.xxxx.common.utils;import lombok.extern.slf4j.Slf4j;
import org.jaudiotagger.audio.AudioFileIO;
import org.jaudiotagger.audio.mp3.MP3AudioHeader;
import org.jaudiotagger.audio.mp3.MP3File;import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;/*** 音频处理工具类* @author Mr.Li* @date 2023-10-26*/
@Slf4j
public class AudioUtils {/*** 二进制流转音频文件* @param binaryData* @param outputFilePath* @throws IOException*/public static boolean convertBinaryToAudio(byte[] binaryData, String outputFilePath) throws IOException {FileOutputStream outputStream = null;try {outputStream = new FileOutputStream(outputFilePath);outputStream.write(binaryData);return true;}catch (Exception e){log.error("convertBinaryToAudio:outputFilePath:{}",outputFilePath,e);return false;}finally {if (outputStream != null) {outputStream.close();}}}/*** 获取AMR格式音频长度* @param file* @return* @throws IOException*/public static int getAmrDuration(File file) throws IOException {long duration = -1;int[] packedSize = { 12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0,0, 0 };RandomAccessFile randomAccessFile = null;try {randomAccessFile = new RandomAccessFile(file, "rw");// 文件的长度long length = file.length();// 设置初始位置int pos = 6;// 初始帧数int frameCount = 0;int packedPos = -1;// 初始数据值byte[] datas = new byte[1];while (pos <= length) {randomAccessFile.seek(pos);if (randomAccessFile.read(datas, 0, 1) != 1) {duration = length > 0 ? ((length - 6) / 650) : 0;break;}packedPos = (datas[0] >> 3) & 0x0F;pos += packedSize[packedPos] + 1;frameCount++;}// 帧数*20duration += frameCount * 20;} catch (Exception e){log.error("getAmrDuration:",e);}finally {if (randomAccessFile != null) {randomAccessFile.close();}}return (int)((duration/1000)+1);}/*** 计算Mp3音频格式时长* @param mp3File* @return*/public static int getMp3Duration(File mp3File) {try {MP3File f = (MP3File) AudioFileIO.read(mp3File);MP3AudioHeader audioHeader = (MP3AudioHeader) f.getAudioHeader();return audioHeader.getTrackLength();} catch (Exception e) {log.error("getMp3Duration:",e);return 0;}}public static void main(String[] args) throws IOException {String path="C:\\Users\\MyPC\\Desktop\\卡布奇诺-王逗逗.mp3";int duration = getMp3Duration(new File(path));System.out.println(duration);}
}

致力于物联网应用开发,目前有一套成熟的物联网底层服务与物联网设备管理系统,并提供API,WebHook,MQTT实现将数据实时有效的推送到客户的云平台,助力客户完成自己的SaaS平台开发。

欢迎对物联网感兴趣的朋友加我微信交流学习。

http://www.wangmingla.cn/news/116703.html

相关文章:

  • 梅兰商贸网站开发设计简介新闻头条今日要闻国内
  • 郑州网站建设哪家公司便宜宁德市自然资源局
  • 新开传奇网站单职业线上推广有哪些
  • 天津做网站首选津坤科技b营销一体化平台
  • 微信公众号上做网站站内优化怎么做
  • 高端网站建设知识环球军事网最新军事新闻最新消息
  • 做印刷品去哪个网站网络营销师证书查询
  • 美橙网站建设整站seo外包
  • 上传网站源码中国国家人才培训网官网
  • 什么网站可以做装修效果图的简述网站内容如何优化
  • 网站图怎么做才能小而清晰泉州搜索推广
  • 私密浏览器免费版图片百度seo营销推广多少钱
  • 杭州设计师网站优化网站seo策略
  • 国外网站服务器免费百度推广代理商赚钱吗
  • 假淘宝网站怎么做网站设计公司哪家专业
  • 新手做代购网站扫货微博seo排名优化
  • 做导航网站赚钱吗宜昌网站seo收费
  • 网站的公告栏怎么做惠州网站制作推广
  • 分类目录网站大全做seo拍照搜索百度识图
  • 做关键词优化需要修改网站标题全网热搜关键词排行榜
  • 源码网站建设教程企业微信会话内容存档
  • 低价服装网站建设微信群发软件
  • 泰安千橙网站建设网站关键词快速排名技术
  • 网站管理员功能百度投稿平台
  • wp博客 婚庆网站模板网页设计自学要多久
  • 网站seo合同三亚百度推广开户
  • 潍坊哪里做网站好真正永久免费网站建设
  • 临沂做拼多多网站今日最新的新闻
  • 沈阳便宜做网站的全国疫情最新情况
  • 阿里云专有网络做网站自己创建一个网站需要多少钱