Parse built-in information of MP3 song files

Source: Internet
Author: User

Parse the built-in information of MP3 song files,Note: Please respect the individual's labor results, and indicate the source for reprinting.

The implementation code is as follows:

/*************************************** * ********************************** File Name: mp3analysis. c ** created on: 2012-8-17 ** Author: Martin (p000034) ** contact: ** Description: parsing MP3 song file built-in information ** modifications: no *** statement: this procedure is only for study and exchange and cannot be used for commercial purposes without the authorization of the author. ** otherwise, the right to pursue legal liability shall be reserved. **************************************** * *********************************/# Include <stdio. h> # include <stdlib. h> /************************************* * ********************** define a structure named MP3 ********** **************************************** * *********/typedef struct tagmp3 {char tag [4]; // tag char name [31]; // song name char singer [31]; // artist name char special [31]; // album name char year [5]; // year char remark [29]; // Remarks char hastrk; // is there a sound track? 0 indicates that the next position is the char TRK of the audio track; // The Char style of the audio track; // style} MP3; /*************************************** * ********************** function: output the information of an MP3 file ********************************** * *************************/void showmp3info (MP3 MP3) {printf ("song details: \ n"); printf ("tag: % s \ n", mp3.tag); printf ("song name: % s \ n ",; printf ("artist name: % s \ n", mp3.singer); printf ("album: % s \ n", mp3.special); printf ("Year: % s \ n ", mp3.year); printf (" Backup Note: % s \ n ", mp3.remark); If (0 = mp3.hastrk) {printf (" audio track: \ n ");} else {printf ("audio track: None \ n");} printf ("audio track: % d \ n", mp3.trk); printf ("style: % x \ n ",;} int main (void) {MP3 mp3music; // defines an MP3 type file * fp = fopen (" D:/test.pdf ", "R"); // open the MP3 file if (null = FP) {// file opening failed printf ("file opening failed! Check whether the "D:/testbench" file exists. \ N "); exit (0);} else {// file opened successfully // read Tag Information fseek (FP,-128l, seek_end); fgets (mp3music. tag, 4, FP); // read the song name fseek (FP,-125l, seek_end); fgets (mp3music. name, 31, FP); // read the singer's name fseek (FP,-95l, seek_end); fgets (mp3music. singer, 31, FP); // read the album name fseek (FP,-65l, seek_end); fgets (mp3music. special, 31, FP); // read year fseek (FP,-35l, seek_end); fgets (mp3music. year, 5, FP); // read the remarks fseek (FP,-31l, seek_end); fgets (mp3music. remark, 29, FP); // read whether the audio track fseek (FP,-3l, seek_end); fgets (& (mp3music. hastrk), 2, FP); // read the audio track fseek (FP,-2L, seek_end); fgets (& (mp3music. TRK), 2, FP); // read style fseek (FP,-1l, seek_end); fgets (& (mp3music. style), 2, FP);} fclose (FP); // close the MP3 file // display the information of the MP3 file showmp3info (mp3music); Return 0 ;}

The system runs normally as follows:


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