Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
G

greycrow

@greycrow
About
Posts
1
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • how to get the duration of an mp3 file
    G greycrow

    If I oversimplify this or you all ready know parts of this, I appologize. But here goes... MP3 files are made up of a bunch of music sections, each having a header. At the end of the file is a TAG 128 bytes long. The Gist of getting the duration of an MP3 is to first get the size of the file, then subtract 128 bytes for the TAG. Divide the number of remaining "Bits" in the file by the bitrate. So to get the file length: . . using System.IO; . . FileStream MP3File; . MP3File = new FileStream("C:\\mySong.mp3", FileMode.Open); . FileLength = MP3File.Length; // gives file length in bytes . And for the duration: . Duration = ((FileLength - 128) * 8) / bitrate; //gives duration in seconds . The problem now lies in getting the bitrate. If you know all your files are say 128kbits/sec you can cheat an get a pretty good estimate. So your formula would be. Duration = ((FileLength - 128) * 8) / (1024*128); The problem is real MP3 files can have different bitrates within individiual song blocks. So it would be neccessary to read each block header for the bitrate and then add everything up at the end. Rather a tedious exercise. Hope that helps a bit greycrow

    C# csharp tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups