有没有办法标记 .wav 文件并在其中写入时间?
我想在每个 .wav 文件中添加一个时间标签。该标签会显示文件何时开始,如果可能的话,还显示结束时间。该时间可能是相对于 UNIX 纪元的。我将如何去做这件事或者甚至可以做到吗?
谢谢
-乔希
I would like to add into each one of my .wav files a time tag. This tag would say when the file has started in time and if possible an end time. The time could be relative to the unix epoch. How would I go about doing this or can it even be done?
Thanks
-Josh
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
来自 http://www.wotsit.org/download.asp?f=波&sc=351595652:
您可以为您的信息添加自己的块,但只有您的工具才会被使用。能够读写它。您可能会发现与其他软件的互操作性问题,这些软件无法正确忽略未知块,或者选择与您为块所做的相同的 ID。块 ID 为 4 个字节,因此在实践中应该有足够的空间来避免该问题,甚至以最严格的意义(“4 个字节的可打印 ASCII 字符”)解释上述文档(“4 个 ASCII 字节”)。
相反,您可以将包含您的信息的单独文件与波形文件一起保存。不会有互操作性问题,但用户需要将文件保存在一起。
From http://www.wotsit.org/download.asp?f=wave&sc=351595652:
You could add your own chunk for your information, but only your tools would be able to read and write it. You may find interoperability problems with other software that doesn't properly ignore unknown chunks, or chooses the same ID as you did for your chunk. Chunk IDs are 4 bytes, so that should be enough room to avoid that problem in practice, even interpreting the above document ("4 ASCII bytes") in the most restrictive sense ("4 bytes of printable ASCII characters").
Instead, you could keep a separate file alongside the wave file with your information. There would be no interoperability problems, but users would be required to keep the files together.
WAV 文件支持有限的、基于文本的标记,这可能适合您。您可以在 INFO 块中指定用户定义的字段 ( http://en.wikipedia.org/wiki /Resource_Interchange_File_Format#Use_of_the_INFO_chunk),这可能适合您的需求,但是没有比在 MP3 中使用 ID3 标签或在 FLAC 中使用 Vorbis 注释更简单的方法了。
我不知道有什么库可以让这个更容易使用,因为我不使用 WAV,但也许 libsndfile 适合您,或者您可以通过将文件读入字节流来自己操作标头,然后使用规范中的信息自行处理标头: http://www.sonicspot.com/guide/wavefiles.html#wavefileheader
否则,为了更简单的时间,您可能希望将 WAV 文件转码为 FLAC,然后将字段写入 FLAC 标记:完整的 FLAC C 和 C++ API 文档位于:http://flac.sourceforge.net/api/index.html
WAV files support limited, text-based tagging, which probably works fine for you. You can specify user-defined fields in the INFO chunk ( http://en.wikipedia.org/wiki/Resource_Interchange_File_Format#Use_of_the_INFO_chunk), which is probably suitable for your needs, but there's no simpler way like you get with ID3 tags in MP3 or Vorbis comments in FLAC.
I don't know of any library that makes this easier to work with, since I don't work with WAV, but maybe libsndfile would work for you, or otherwise you could manipulate the header yourself by reading in the file into a byte stream, and then processing the header yourself using the information from the specifications: http://www.sonicspot.com/guide/wavefiles.html#wavefileheader
Otherwise, for a simpler time, you might want to transcode your WAV files to FLAC and then write fields to the FLAC tag: Full FLAC C and C++ API documentation here: http://flac.sourceforge.net/api/index.html
我不确定是否有一种常见的方法可以做到这一点(例如 jpeg 中的 exif 标签),但如果其他一切都失败,您可以尝试使用 http://en.wikipedia.org/wiki/Steganography
这是一种将消息编码到文件中的方法,尤其是图片和音频文件,仅稍微改变内容。但我不知道将该消息编码/解码到文件中需要花费多少精力。
I am not sure if there is a common way to do that (like exif tags in jpeg), but if everything else fails you could try to use http://en.wikipedia.org/wiki/Steganography
Thats a method to code Messages into files, especially pictures and audiofiles, altering the content only sligthly. but i dont know how much efford it would be to code/decode that message into a file.
WAV 文件是 RIFF 文件,其设计目的是允许在不破坏文件的情况下添加任意数据块。其他程序(只要您选择的块标签不与其他程序冲突)。
如果您使用的是 Windows,有一些函数可以帮助您操作此类文件,例如 mmioCreateChunk。
WAV files are RIFF files, which are designed to allow adding chunks of arbitrary data without breaking the file for other programs (so long as your chosen chunk tag doesn't clash with anybody else).
If you are on Windows, there are some functions to help you manipulate such files, e.g. mmioCreateChunk.