如何在VB.NET中将音乐文件合并为一个单独的文件? [英] How to merge to music file into a one separate file in VB.NET ?

查看:154
本文介绍了如何在VB.NET中将音乐文件合并为一个单独的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将音乐文件合并到vb.net中的一个单独文件中?





以下我尝试过的代码合并到音乐文件中,但由于长度或其他原因,只播放第一首音乐。 !!!



我尝试过:



 Dim s1 As Byte()= File.ReadAllBytes(e:\ Musus\Voice 001.mp3)
Dim s2 As Byte()= File.ReadAllBytes(e:\ Music \\ _Doice 002.mp3)
Dim adWithSong As Byte()= New Byte(s1.Length + s2.Length){}
s1.CopyTo(adWithSong,0)
s2.CopyTo (adWithSong,s1.Length)
Dim newFilePath As String =e:\ Musus \ test1.mp3
File.WriteAllBytes(newFilePath,adWithSong)

解决方案

您不能简单地连接声音或视频文件。



声音和视频文件包含结构化数据带有标题,提供有关后续数据的详细信息以及其他信息,例如提供有关文件信息但与实际声音数据无关的标签。



请参阅MP3文件格式;



MP3文件格式规范 [ ^ ]



MP3 - 维基百科 [ ^ ]



此外,将MP3放在本网站的搜索框中,查看操作MP3的代码示例。


主要问题是你对MP3文件的误解。

你的罐头只是追加一个接一个,并期望得到一个大的mp3文件。

基本上,你需要一个可以解码MP3文件的库和:

加载/解码第一个mp3文件

加载/解码第二个mp3文件

使用库合并它们

编码/保存大mp3

how to merge to music file into a one separate file in vb.net ?



the following code that i have tried merges to music file but only first music plays because of length or something. !!!

What I have tried:

Dim s1 As Byte() = File.ReadAllBytes("e:\Music\Voice 001.mp3")
      Dim s2 As Byte() = File.ReadAllBytes("e:\Music\Voice 002.mp3")
      Dim adWithSong As Byte() = New Byte(s1.Length + s2.Length) {}
      s1.CopyTo(adWithSong, 0)
      s2.CopyTo(adWithSong, s1.Length)
      Dim newFilePath As String = "e:\Music\test1.mp3"
      File.WriteAllBytes(newFilePath, adWithSong)

解决方案

You cannot simply concatenate sound or video files.

Sound and video files contain structured data with headers giving details on the data that follows and other information such as tags that give information about the file but are nothing to do with the actual sound data.

See the MP3 file format;

MP3 File Format Specification[^]

MP3 - Wikipedia[^]

Also, put MP3 in the search box on this site to see code examples of manipulating MP3's.


The main problem is your misconception of MP3 files.
Your can't just append 1 after the other and expect getting 1 big mp3 file that work.
Basically, you need a library that can decode an MP3 file and:
Load/decode the first mp3 file
Load/decode the second mp3 file
merge them using the library
encode/save the big mp3


这篇关于如何在VB.NET中将音乐文件合并为一个单独的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆