Use getID3 to write ID3v2 tags to mp3 files

Source: Internet
Author: User
: This article describes how to use getID3 to write the ID3v2 tag to an mp3 file. if you are interested in the PHP Tutorial, refer to it. Use getid3to write the ID3v2 tag to the hosts file

Directory

  • Use getID3 to write ID3v2 tags to mp3 files
      • Directory
      • Introduction
      • ID3 tag
      • Description
      • Implementation code
      • Read information after successful operation

Introduction

Recently, a project needs to write the handwriting records of the canvas into the TXXX tag of ID3v2 in mp3.
-Official getID3 website
ID3-Wikipedia

ID3 tag

ID3 is usually located in several bytes at the beginning or end of an mp3 file. it carries information about the mp3 artist, title, album name, age, style, and so on, this information is called ID3 information. ID3 information is divided into two versions: v1 and v2. The ID3 of v1 is 128 bytes at the end of the mp3 file. it starts with a TAG and follows the song information. V2 is generally at the beginning of mp3 and can store large amounts of information such as lyrics, pictures of the album, and so on. -- [Baidu encyclopedia]

Description

> The handwriting tag is a string with a certain length, and the TXXX tag is used to save text data.

Implementation code

Write the pen data into the inventory file:

Require_once ('. /getid3/write. id3v2. php '); $ tagwriter = new getid3_write_id3v2; // file path $ tagwriter-> filename = '. /test.mp3 '; // tag content $ TagData = array ('txxx' => array ('encodingid' => 1, 'description' => 'txxx ', 'data' => 'handwriting data'); $ tagwriter-> tag_data = $ TagData; // use the WriteID3v2 method to write if ($ tagwriter-> WriteID3v2 ()) {echo 'successfully wrote tags
'; If (! Empty ($ tagwriter-> warnings) {echo 'There were some warnings:
'. Implode ('

', $ Tagwriter-> warnings) ;}} else {echo 'failed' to write tags!
'. Implode (' ', $ Tagwriter-> errors );}

The TXXX tag of the reading/Reading hosts file:

require_once('./getid3/getid3.php');$filename = './test.mp3';$getID3 = new getID3;$ThisFileInfo = $getID3->analyze($filename);$map['filename']=$ThisFileInfo['filename'];$map['TXXX']=$ThisFileInfo['id3v2']['TXXX'][0]['data'];exit(json_encode($map));

Read information after successful operation

'). AddClass ('pre-numbering '). hide (); $ (this ). addClass ('Has-numbering '). parent (). append ($ numbering); for (I = 1; I <= lines; I ++) {$ numbering. append ($ ('
  • '). Text (I) ;}; $ numbering. fadeIn (1700) ;}) ;}; script

    The preceding section describes how to use getID3 to write the ID3v2 tag to an mp3 file, including related content. if you are interested in the PHP Tutorial.

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.