Aus Sound (.mp3) Dateien die Dauer herauslesen!? [Erledigt]

Übersicht BlitzBasic Allgemein

Neue Antwort erstellen

 

KillerFliege

Betreff: Aus Sound (.mp3) Dateien die Dauer herauslesen!? [Erledigt]

BeitragDo, Aug 14, 2008 14:00
Antworten mit Zitat
Benutzer-Profile anzeigen
Wie kann man aus einer Musik datei (.mp3) die zeit auslesen. Also das lied geht 3:20.
Weis einer wie das geht?
Einfach mit den Datei befehlen? Was ich fast nicht glaube.
  • Zuletzt bearbeitet von KillerFliege am Do, Aug 14, 2008 14:16, insgesamt einmal bearbeitet
 

KillerFliege

BeitragDo, Aug 14, 2008 14:07
Antworten mit Zitat
Benutzer-Profile anzeigen
LOL?
Habe die Boardsuche verwendet Very Happy aber nix gefunden.
Nun habe ich Google/Yahoo verwendet udn werde auf diese Seite verlinkt Very Happy

https://www.blitzforum.de/foru...hp?t=25332

Lies mir das mal durch, da mir das bestimmt schon helfen könnte Wink

EDIT:
Ok leute Smile das funktioniert mal sowas von GEIL!!
Hat sich also Erledigt Smile
  • Zuletzt bearbeitet von KillerFliege am Do, Aug 14, 2008 14:14, insgesamt einmal bearbeitet

EPS

BeitragDo, Aug 14, 2008 14:08
Antworten mit Zitat
Benutzer-Profile anzeigen
Hab das hier in meiner Restebox gefunden - ich denke mal es müsste gehen:

Code: [AUSKLAPPEN]
; ID: 967
; Author: Klaas
; Date: 2004-03-14 09:16:26
; Title: mp3 Infos (including Audiframes and id3v2)
; Description: analyses a mp3file

; Modified by East-Power-Soft
; Added playtime calculation. (Source: http://www.activevb.de/tipps/vb6tipps/tipp0487.html)
; and cutout all the stuff whats not needed 4 use

;def

Global mp3_artist$, mp3_artist1$
Global mp3_songname$, mp3_songname1$
Global mp3_playtime$

Global mp3_FileSize

Dim avFrameRates#(3)
avFrameRates(0) = 38.5
avFrameRates(1) = 32.5
avFrameRates(2) = 27.8
avFrameRates(3) = 0

Dim mp3_bri(16)
mp3_bri(0) = 0
mp3_bri(1) = 32
mp3_bri(2) = 40
mp3_bri(3) = 48
mp3_bri(4) = 56
mp3_bri(5) = 64
mp3_bri(6) = 80
mp3_bri(7) = 96
mp3_bri(8) = 112
mp3_bri(9) = 128
mp3_bri(10) = 160
mp3_bri(11) = 192
mp3_bri(12) = 224
mp3_bri(13) = 256
mp3_bri(14) = 320
mp3_bri(15) = 0

Dim mp3_sri(4)
mp3_sri(0) = 44100
mp3_sri(1) = 48000
mp3_sri(2) = 32000
mp3_sri(3) = 0

Type id3v2
   Field key$
   Field flags
   Field Dat$
   Field size
   Field start
End Type

Type AudioFrame
   Field Bitrate
   Field samplerate
   Field padding
   Field seconds
   Field framelen
End Type


Function getmp3infos(filename$)
;==============================================================================================================
; Ermittle MP3 Dateiinformationen (Artist, Titel und Spielzeit)
; Rückgabe erfolgt in den Variablen: mp3_artist$, mp3_songname$ und mp3_playtime$
;==============================================================================================================

   ;--> lösche alte Types
   For a.audioframe = Each audioframe
      Delete a
   Next
   For t.id3v2 = Each id3v2
      Delete t
   Next

   readTagv1(filename)
   analyseMP3(filename)

   If mp3_artist$ = "" Then mp3_artist$ = mp3_artist1$
   If mp3_songname$ = "" Then mp3_songname$ = mp3_songname1$

   ticker_dir = False
   ticker_timer = MilliSecs() + 1000
   ticker_scroll = 0
   
End Function



Function analyseMP3(filename$)
   If Not FileType(filename) = 1 Then Return

   file = ReadFile(filename)
   mp3_FileSize = FileSize(filename)

   readTagv2(file)
   
   While Not Eof(file)
      a.audioframe = mp3_readAudioFrame.AudioFrame(file)
      If a = Null Then Exit
   Wend
   
   CloseFile file

   mp3_playtime$ = ""

   a.audioframe = Last AudioFrame
   If a<>Null Then
      min = a\seconds / 60
      sek = a\seconds - min * 60
      mp3_playtime$ = Str$(min)+":"+Right$("00"+Str$(sek),2)
   EndIf
End Function



Function mp3_readAudioFrame.AudioFrame(file)
   
   pos = FilePos(file)
   
   b1 = ReadByte(file)
   b2 = ReadByte(file)
   b3 = ReadByte(file)
   b4 = ReadByte(file)
   
   If b1 <> $ff And (b2 And 224) <> 224
      SeekFile(file,FilePos(file)-4)
      Return Null
   EndIf
   
   a.AudioFrame = New AudioFrame
   
   BitrateID = (b3 And $f0) Shr 4
   a\BitRate = mp3_bri(BitrateID) * 1000
   
   SamplerateID = (b3 And $c) Shr 2
   a\SampleRate = mp3_sri(SamplerateID)
   
   a\Padding = (b3 And $2) Shr 1

   a\FrameLen = Floor((144.0 * Float(a\BitRate) / Float(a\SampleRate) ) + a\Padding)
   
   m_lFrames# = mp3_FileSize / a\FrameLen
   a\seconds = m_lFrames / avFrameRates(SamplerateID)

   SeekFile(file,FilePos(file)+a\framelen-4)
   Return a
End Function



Function readTagv1(filename$)
   mp3_songname$ = ""
   mp3_artist$ = ""

   If Not FileType(filename) = 1 Then Return

   file = ReadFile(filename)
   SeekFile(file,FileSize(filename)-128)
   
   For i=0 To 2
      txt$ = txt$ + Chr(ReadByte(file))
   Next
   
   If txt = "TAG"
      For i=0 To 29
         mp3_songname$ = mp3_songname$ + Chr(ReadByte(file))
      Next
      For i=0 To 29
         mp3_artist$ = mp3_artist$ + Chr(ReadByte(file))
      Next
      mp3_songname$ = Trim(mp3_songname$)
      mp3_artist$ = Trim(mp3_artist$)
   EndIf
   
   CloseFile file
   
End Function



Function readTagv2(file)      
   mp3_artist1$ = ""
   mp3_songname1$ = ""

   SeekFile(file,0)
   For i=0 To 2
      txt$ = txt$ + Chr(ReadByte(file))
   Next
   
   If txt = "ID3"
      
      ;read TAG version
      hiVersion = ReadByte(file)
      lowVersion = ReadByte(file)

      ;read flags
      flags = ReadByte(file)
      
      ;read size of tag
      b = ReadInt(file)
      
      size = syncsafeInt(b)

      While tagpos < size
         ;read frame TAG
         txt = ""

         b1 = ReadByte(file)
         tagpos = tagpos + 1
         If b1
            t.id3v2 = New id3v2
            t\start = FilePos(file)-1
            
            b2 = ReadByte(file)
            b3 = ReadByte(file)
            b4 = ReadByte(file)
            tagpos = tagpos + 3

            txt$ = Chr(b1) + Chr(b2) + Chr(b3) + Chr(b4)
            t\key = txt
            
            framesize = syncsafeInt(ReadInt(file))
            tagpos = tagpos + 4
            t\size = framesize
            
            flags = ReadShort(file)
            tagpos = tagpos + 2
            t\flags = flags
                        
            txt$ = ""
            For i= 1 To framesize
               txt = txt + Chr(ReadByte(file))
               tagpos = tagpos + 1
            Next
            t\dat$ = Trim(txt)
         EndIf
         ;WaitKey
      Wend
   Else
      SeekFile(file,0)
   EndIf
   
   For t.id3v2 = Each id3v2
      If t\key="TPE1" Then mp3_artist1$ = Trim(t\dat)
      If t\key="TIT2" Then mp3_songname1$ = Trim(t\dat)
   Next
End Function



Function syncsafeInt(b)
   
   b1 = b And $ff000000
   b2 = b And $00ff0000
   b3 = b And $0000ff00
   b4 = b And $000000ff
   
   b1 = (b And $ff000000) Shr 24
   b2 = (b And $00ff0000) Shr 8
   b3 = (b And $0000ff00) Shr 8
   b4 = (b And $000000ff) Shr 24

   b4 = b4 Shr 3
   b3 = b3 Shr 2
   b2 = b2 Shr 1
   
   size = b4 Or b3 Or b2 Or b1
   Return size
End Function
mGUI - Graphical User Interface für Blitz3D...Informationen gibt es hier

Man kann sich öfter als zweimal im Leben halb tot lachen.
 

KillerFliege

BeitragDo, Aug 14, 2008 14:16
Antworten mit Zitat
Benutzer-Profile anzeigen
Danke Wink
Das andere funktioniert auch tadellos Smile
Trotzdem danke fürs Restebox durchsuchen. Meine es ernst!

Neue Antwort erstellen


Übersicht BlitzBasic Allgemein

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group