Results 1 to 8 of 8

Thread: [RESOLVED] Verify MP3

  1. #1

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Resolved [RESOLVED] Verify MP3

    How can I do server-side verification to make sure the uploaded file is an MP3?

    Using the MIME type/content type works fine for Internet Explorer, but doesn't seem to work with FireFox.

    I don't want to rely on reading ID3 tags since not all MP3s have them. I appreciate any help.

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Verify MP3

    you could probably use PEAR's mp3_id class. from a glance, it looks like the read method in that class will give an error if reading a non-mp3 file.

    http://pear.php.net/package/MP3_Id/d...tml#methodread

  3. #3

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Verify MP3

    Thanks, I'm going to look into that & test it out.

  4. #4

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Verify MP3

    Doesn't seem to be working. It only seems to be able to read ID3 tags (artist, genre, etc.). As I said, I don't want to verify an MP3 by it's ID tags, because not all MP3s contain them.

    And it also doesn't seem to raise an error if the file is not an MP3.

    I want something that can read the length, channels (mono/stereo), bitrate, and sample rate (44100, 48000, etc.).

    Any ideas?

  5. #5
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

  6. #6

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Verify MP3

    Thanks I'm looking at that now.

  7. #7

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Verify MP3

    Works perfectly, thanks a lot!

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: [RESOLVED] Verify MP3

    You can also check the file directly. An MP3 file that has no ID3v2 header starts with the bit pattern 111111111110, followed by 111 or 011.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width