0

I have created a Youtube to mp3 script with PHP. I would like to add the ability to add metadata of the title, artists, album, etc. I have created a test PHP script, using the id3_set_tag() function to add metadata to an MP3 but when I load the page it is blank and the file remains untouched.

<?php
$data = array(
              "title" => "Re:Start",
              "artist" => "Re:\Legion",
              "comment" => "A nice track"
             );
$result = id3_set_tag( "Test.mp3", $data, ID3_V1_0 );
if ($result === true) {
    echo "Tag successfully updated\n";
}
?>

Here are the Apache/PHP logs:

[Mon Jun 11 17:54:39.197984 2018] [php7:error] [pid 1458] [client 127.0.0.1:51864] PHP Fatal error: Uncaught Error: Call to undefined function id3_set_tag() in /Library/WebServer/Documents/index.php:7\nStack trace:\n#0 {main}\n thrown in /Library/WebServer/Documents/index.php on line 7

Specs: Apache

PHP 7

macOS High Sierra

So my question is: How do I add song metadata to a MP3 file with PHP on Mac?

Shoukat Mirza
  • 800
  • 9
  • 19
JBis
  • 827
  • 1
  • 10
  • 26
  • 1
    Why would this be any different on macOS than on any other platform that PHP runs on? You should check with `phpinfo()` if that function is compiled in. – tadman Jun 11 '18 at 22:05
  • @tadman Not exactly sure how to check, but went to phpinfo(), did a quick CMD - F and no results for id3. Maybe another way to do it? P.S. Nothing in `disabled_functions` either. – JBis Jun 11 '18 at 22:08
  • @tadman According to the guide [here](https://www.a2hosting.com/kb/developer-corner/php/determine-if-a-php-function-is-available), it is not enabled. Not sure what to do about that. – JBis Jun 11 '18 at 22:11
  • The documentation covers [the installation procedure](http://php.net/manual/en/id3.installation.php). – tadman Jun 11 '18 at 22:11
  • @tadman I appreciate your help! Unfortunately the link seems very vague. It says I should edit a file but I am not sure where that file is. – JBis Jun 11 '18 at 22:17
  • @tadman Thanks for your help. I am installing it as we speak. Will report back after. – JBis Jun 11 '18 at 22:26
  • 1
    You might try this. It is a relatively recent tutorial, but Apple has recently restricted some directories: https://sergeyzhuk.me/2016/11/07/osx-pecl-install/ – dmgig Jun 11 '18 at 22:28
  • @tadman Installed from [here](https://github.com/larsbs/id3v2lib) installed successfully, although I couldn't find the file or line they were talking about in your link. But still it appears the functions is not installed. – JBis Jun 11 '18 at 22:33

0 Answers0