#AppType CONSOLE
Dim mnIn As Integer, mnOut As Integer
Dim %i, $sBuff, %nPos
Flv2Mp3( "Stupeflip - Je fume pu d'shit.flv" )
Function Flv2Mp3(ByVal szFLVFile As String) As Integer
mnIn = FileOpen( szFLVFile, BINARY_INPUT )
Flv2Mp3 = False
If (ReadUInt32() = &H464C5601) Then
ReadUInt8() 'flags
nPos = ReadUInt32()
FileSeek( mnIn, nPos )'+1
ReadUInt32() 'prevTagSize
Do Until FileEof(mnIn)
ReadTag()
ReadUInt32() 'prevTagSize
Loop
If mnOut Then
Flv2Mp3 = True
FileClose( mnOut )
mnOut = 0
End If
End If
FileClose( mnIn )
End Function
Sub ReadTag()
Dim eTagType As Integer, eMediaType As Integer, nLength As Integer, xbData As String
Static xTotal As Integer
eTagType = ReadUInt8()
nLength = ReadUInt24()
ReadUInt32() 'timeStamp
ReadUInt24() 'streamID
If nLength Then
eMediaType = ReadUInt8()
xbData = ReadBytes(nLength - 1)
'# Audio et de type MP3
If (eTagType = &H8) And (eMediaType 16) = 2 Then
If mnOut = 0 Then
xTotal = 0
mnOut = FileOpen( ".out.mp3", BINARY_NEW )
End If
xTotal = xTotal + nLength
FilePut( mnOut, xbData )
Locate(5, 5): Print xTotal, " MP3 bytes written"
End If
End If
End Sub
Function ReadBytes(vnLength As Integer)
sBuff = FileGet(mnIn, vnLength): Return sBuff
End Function
Function ReadUInt32() As Integer
sBuff = FileGet( mnIn, 4): Return CVI(sBuff, 1)
End Function
Function ReadUInt24() As Integer
sBuff = FileGet( mnIn, 3): Return CVI(sBuff, 1)
End Function
Function ReadUInt8() As Integer
sBuff = FileGet( mnIn, 1): Return CVI(sBuff, 1)
End Function
Cette contribution était de : http://www.gratilog.net/xoops/newbb/viewtopic.php?forum=2&topic_id=3038&post_id=15906