有没有办法标记 .wav 文件并在其中写入时间?

发布于 2024-10-18 13:15:13 字数 119 浏览 9 评论 0原文

我想在每个 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

夜吻♂芭芘 2024-10-25 13:15:13

来自 http://www.wotsit.org/download.asp?f=波&sc=351595652

WAVE 文件是许多不同类型块的集合。 ...其他可选块包括定义提示点、列出仪器参数、存储特定于应用程序的信息等。

您可以为您的信息添加自己的块,但只有您的工具才会被使用。能够读写它。您可能会发现与其他软件的互操作性问题,这些软件无法正确忽略未知块,或者选择与您为块所做的相同的 ID。块 ID 为 4 个字节,因此在实践中应该有足够的空间来避免该问题,甚至以最严格的意义(“4 个字节的可打印 ASCII 字符”)解释上述文档(“4 个 ASCII 字节”)。

相反,您可以将包含您的信息的单独文件与波形文件一起保存。不会有互操作性问题,但用户需要将文件保存在一起。

From http://www.wotsit.org/download.asp?f=wave&sc=351595652:

A WAVE file is a collection of a number of different types of chunks. ... Among the other optional chunks are ones which define cue points, list instrument parameters, store application-specific information, etc.

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.

本王不退位尔等都是臣 2024-10-25 13:15:13

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

痴意少年 2024-10-25 13:15:13

我不确定是否有一种常见的方法可以做到这一点(例如 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.

愿与i 2024-10-25 13:15:13

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文