Writing ID3v2 tags to mp3 files using getID3

Source: Internet
Author: User
Tags id3
Writing ID3v2 tags to. mp3 files using getID3

Directory

    • Writing ID3v2 tags to mp3 files using getID3
        • Directory
        • Brief introduction
        • ID3 Label
        • Description
        • Implementation code
        • Information read after successful operation

Brief introduction

A recent project needs to implement a txxx label that writes the handwriting records of the canvas artboard to the ID3v2 in mp3
-GetID3 Official website
-Id3-wikipedia

ID3 Label

ID3, typically located in a number of bytes at the beginning or end of a MP3 file, is appended with information about the MP3 's singer, title, album name, age, style, and so on, which is known as ID3 information, ID3 information is divided into two versions, V1 and V2 editions. Where: V1 version of the ID3 at the end of the MP3 file 128 bytes, starting with the tag three characters, followed by the song information. V2 version is generally located at the beginning of MP3, can store lyrics, the album's Pictures and other large-capacity information. --[Baidu Encyclopedia]

Description

> 笔迹标签为具有一定长度的字符串,而TXXX标签就是用来保存文本数据

Implementation code

Write handwriting data to the. mp3 file:

require_once('./getid3/write.id3v2.php ');$tagwriter=NewGetid3_write_id3v2;//file path$tagwriter->filename ='./test.mp3 ';//label content$TagData=Array(' TXXX '=Array(Array(' Encodingid '=1,' description '=' TXXX ',' Data '=' handwriting data '))            );$tagwriter->tag_data =$TagData;//Using the Writeid3v2 method to writeif($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); }

Read the. mp3 file Txxx Tags:

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

Information read 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); }); });

    The above describes the use of getID3 to MP3 files to write ID3v2 tags, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.