python - 什么是用于在 Python 中验证文件的好音频库?

标签 python validation audio mp3

我已经在检查内容类型、大小和扩展名 ( Django (audio) File Validation ),但我需要一个库来读取文件并确认它确实是我希望的(主要是 mp3 和 mp4) .

我来过这里:http://wiki.python.org/moin/Audio/但没有运气。在这里呆了一段时间,我有点迷失在树林里。依靠如此大的时间来完成这整个事情......

提前致谢。

编辑: 我已经(在 Django 中)使用 UploadedFile.content_type() :

"The content-type header uploaded with the file (e.g. text/plain or application/pdf). Like any data supplied by the user, you shouldn't trust that the uploaded file is actually this type. You'll still need to validate that the file contains the content that the content-type header claims -- "trust but verify."

所以,我已经在阅读标题了。但是我怎样才能验证文件的实际内容呢?

最佳答案

如果仅仅检查 header 还不够好,我建议使用 mutagen 加载文件。如果不正确,它应该抛出异常。

仅供引用,我认为您的方法不是很有可扩展性。 真的有必要读取文件的每个字节吗?您不信任文件头的原因是什么?

关于python - 什么是用于在 Python 中验证文件的好音频库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6541639/

相关文章:

Python Pandas : Return indices of all rows like another row

python - 如何使用 python urllib2.urlopen 打开 facebook/gmail/身份验证网站?

javascript - "Initial"与 "Eventual"验证

jQuery 验证 - 验证具有相同名称和 ID 的多个表单

使用 Golang 对可选字段进行 JSON 模式验证

c# - 使用 NAudio 解码 mu-law 音频

python - csrf_exempt 的用例

javascript - Backbone.js音频控件

java - 在 Java 中同时播放 .mp3 和一系列音符 (MIDI)

python - 梯度下降多项式回归中权重爆炸