AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

mp3 duration

Ein Thema von DmVinny · begonnen am 3. Apr 2009 · letzter Beitrag vom 4. Apr 2009
 
Wishmaster

Registriert seit: 14. Sep 2002
Ort: Steinbach, MB, Canada
301 Beiträge
 
Delphi XE2 Architect
 
#5

Re: mp3 duration

  Alt 4. Apr 2009, 08:55
Try Audio Tools Library 2.3 it works with CBR and VBR
http://mac.sourceforge.net/atl/


AudioGenie is a fast 32Bit ActiveX-OCX/Dll with over 345 functions to read
audio file information (like Bitrate, Samplerate, Frames, Duration, Version-Number, etc).
http://www.audiogenie.de/en/index.htm

Or

Bass.dll (http://www.un4seen.com/)
Delphi-Quellcode:

function TAudioEngine.Get_MP3_Bitrate: WORD;
const
MPEG_BIT_RATES: array[1..3] of array[1..3] of array[0..15] of word = ((
      { Version 1, Layer I }
      (0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,0),
      { Version 1, Layer II }
      (0,32,48,56, 64, 80, 96,112,128,160,192,224,256,320,384,0),
      { Version 1, Layer III }
      (0,32,40,48, 56, 64, 80, 96,112,128,160,192,224,256,320,0)),
      { Version 2, Layer I }
      ((0,32,48, 56, 64, 80, 96,112,128,144,160,176,192,224,256,0),
      { Version 2, Layer II }
      (0, 8,16,24, 32, 40, 48, 56, 64, 80, 96, 112,128,144,160,0),
      { Version 2, Layer III }
      (0, 8,16,24, 32, 40, 48, 56, 64, 80, 96, 112,128,144,160,0)),
      { Version 2.5, Layer I }
      ((0,32,48, 56, 64, 80, 96,112,128,144,160,176,192,224,256,0),
      { Version 2.5, Layer II }
      (0, 8,16,24, 32, 40, 48, 56, 64, 80, 96, 112,128,144,160,0),
      { Version 2.5, Layer III }
      (0, 8,16,24, 32, 40, 48, 56, 64, 80, 96, 112,128,144,160,0)
    ));
var
  framehead, fpos: DWORD;
  Version, layer, bitrate_index: DWORD;
  fHandle : integer;
  FileFS : THandleStream;
begin

    fpos := BASS_StreamGetFilePosition(Channel, BASS_FILEPOS_DECODE) +
            BASS_StreamGetFilePosition(Channel, BASS_FILEPOS_START);

    fHandle := CreateFile(PChar(Cur_FileName), GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_ATTRIBUTE_ARCHIVE,0);
 if fHandle = INVALID_HANDLE_VALUE then
  exit;
   FileFS := THandleStream.Create(fHandle);
   FileFS.Seek(fpos, soFromBeginning);
   FileFS.Read(framehead, SizeOf(framehead));
   FileFS.Free;
  CloseHandle(fHandle);
  framehead := ((framehead and $ff) shl 24) or
               ((framehead and $ff00) shl 8) or
               ((framehead and $ff0000) shr 8) or
               ((framehead and $ff000000)shr 24); // reverse byte order

  if ((framehead shr 21) = $7ff) then // got frame sync
   begin
    layer := (framehead shr 19) and 3;
    version := (framehead shr 17) and 3;
    bitrate_index := (framehead shr 12) and 15;
    Result := MPEG_BIT_RATES[version][layer][bitrate_index];
  end
 else
  Result:= 0;
end;

Only for CBR (Bass.dll)

Delphi-Quellcode:
var
  fFileSize, fBitRate : DWORD;
  fFloatPos : FLOAT;

  fFileSize:= BASS_StreamGetFilePosition(Channel, BASS_FILEPOS_END);
  fFloatPos:= BASS_ChannelBytes2Seconds(Channel, BASS_StreamGetLength(Channel));


        fBitRate:= Trunc((fFileSize /(125 * fFloatPos))+0.5);
       if Odd(fBitRate) then
        Dec(fBitRate);
      Result:= fBitRate;



have fun
  Mit Zitat antworten Zitat
 

Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:18 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz