简体   繁体   English

如何在php中读取mp3元数据

[英]How to read mp3 metadata in php

My problem is simple, i need to read/write metadada from/into a mp3 file from a php script, but I can't find any reliable sorce of information.我的问题很简单,我需要从 php 脚本读取/写入 mp3 文件中的元数据,但我找不到任何可靠的信息源。 I'm over a week searching for answers but no real solution.我花了一个多星期寻找答案,但没有真正的解决方案。

To explain my self a little better, I need to upload a mp3 file that has metadata attached, read this data and store in my database.为了更好地解释我自己,我需要上传一个附有元数据的 mp3 文件,读取这些数据并存储在我的数据库中。 After thar initial load, any new mp3 files that will be sent, will not have any metadata, and my system must insert some data into it, like track name, author, and a few others.在初始加载后,将发送的任何新 mp3 文件都不会包含任何元数据,我的系统必须向其中插入一些数据,例如曲目名称、作者和其他一些数据。

I can't find the a working solution for this read/write metadata anywhere, just some offline docs and outdated information.我无法在任何地方找到此读/写元数据的有效解决方案,只有一些离线文档和过时的信息。

If your path to your mp3 file is for example "/var/lib/my_mixtape.mp3", then give the code below a try:例如,如果您的 mp3 文件的路径是“/var/lib/my_mixtape.mp3”,请尝试以下代码:

$mp3FileLocation = "/var/lib/my_mixtape.mp3";
$metaData = id3_get_tag($mp3FileLocation);

// Fetch the necessary information from the $meta

For further reference, checkout the PHP documentation on the id3 function.如需进一步参考,请查看有关 id3 函数的PHP 文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM