关于MP3 文件 格式 使用Java爬取时 音轨卡顿问题

qq_35530042 2018-05-21 07:39:10
前提情况是这样的.
由于想把新东方四级音频下载下来 ,但是没提供一键下载的 所以自己写了个爬虫
现在单独下载时发现问题.
下载下来 能听 但是会跟失真一样 卡卡卡 的一卡一卡的声音 .对MP3格式不解.
是我下载方式不对还是需要特定的爬取编码
还是我应该加上MP3 的特定音频信息给文件.

最后贴上代码:

HttpURLConnection urlConnection = (HttpURLConnection) new URL("http://download.dogwood.com.cn/online/4jlxbx/35.mp3").openConnection();
//开启链接
urlConnection.connect();
InputStream inputStream = urlConnection.getInputStream();
BufferedInputStream bis = new BufferedInputStream(inputStream);

File temp = new File(new File("E:\\360Downloads\\TempFile"), "01.mp3");
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(temp,true));
byte[] b = new byte[1024];
int read = bis.read(b );
while (-1 !=bis.read(b)) {
bos.write(b);
bos.flush();
}
bos.close();
bis.close();


...全文
885 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
South丶Wind 2021-01-12
  • 打赏
  • 举报
回复
+1,爬取下来的音乐卡顿
木秀林 2018-05-21
  • 打赏
  • 举报
回复
上面代码有点问题 重新改下

public class Application {
	public static void main(String[] args) throws MalformedURLException,
			IOException {
		HttpURLConnection urlConnection = (HttpURLConnection) new URL(
				"http://download.dogwood.com.cn/online/4jlxbx/35.mp3")
				.openConnection();
		// 开启链接
		urlConnection.connect();
		InputStream inputStream = urlConnection.getInputStream();

		File temp = new File(new File("E:\\360Downloads\\TempFile"), "01.mp3");
		FileOutputStream fileOutputStream = new FileOutputStream(temp, true);
		byte[] b = new byte[1024];
		while (-1 != inputStream.read(b)) {
			fileOutputStream.write(b);
			fileOutputStream.flush();
		}
		fileOutputStream.close();
		inputStream.close();
	}
}

这种方法还是会有卡顿 声音会有那种喀喀喀的声音

2,543

社区成员

发帖
与我相关
我的任务
社区描述
专题开发/技术/项目 多媒体/流媒体开发
社区管理员
  • 多媒体/流媒体开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧