Google Video (*.gvi) to DivX (*.divX) converter
Posted: Mon Jul 30, 2007 8:55 pm
The subject should do it...
fsw
Code: Select all
; Google Video (*.gvi) to DivX (*.divX) converter
; Removes the Google header and changes the file extension
; to avoid playback issues with various video players
; Warning: more checks should be implemented
; On the other side, it's only an example...
; ...with a lot of IF's
; fsw (July 2007)
;
; more info:
; http://en.wikipedia.org/wiki/Google_Video#GVI_format_and_conversion
#InFile = 1
#OutFile = 2
file$ = OpenFileRequester("Select a file","","Google Video File|*.gvi|All files|*.*",0)
If file$
If ReadFile(#InFile, file$)
If ReadByte(#InFile) = 82 ;R
If ReadByte(#InFile) = 73 ;I
If ReadByte(#InFile) = 70 ;F
If ReadByte(#InFile) = 70 ;F
TotalLength.l = Lof(#InFile)
FileSeek(#InFile, 0)
Repeat
Char.b = ReadByte(#InFile)
Until Char = 76 ;L
ListPos.l = Loc(#InFile) - 1
If ReadByte(#InFile) = 73 ;I
If ReadByte(#InFile) = 83 ;S
If ReadByte(#InFile) = 84 ;T
;All ok "LIST" found
;search again
Repeat
Char.b = ReadByte(#InFile)
Until Char = 76 ;L
CorrectPos.l = Loc(#InFile) - 1
If ReadByte(#InFile) = 73 ;I
If ReadByte(#InFile) = 83 ;S
If ReadByte(#InFile) = 84 ;T
;All ok correct "LIST" found
Debug ReplaceString(file$, ".gvi", ".divX", 1)
If OpenFile(#OutFile, ReplaceString(file$, ".gvi", ".divX", 1))
FileSeek(#InFile, 0)
*MemoryID = AllocateMemory(ListPos)
ReadData(#InFile, *MemoryID, ListPos)
WriteData(#OutFile, *MemoryID, ListPos)
FreeMemory(*MemoryID)
FileSeek(#InFile, CorrectPos)
*MemoryID = AllocateMemory(TotalLength - CorrectPos)
ReadData(#InFile, *MemoryID, TotalLength - CorrectPos)
WriteData(#OutFile, *MemoryID, TotalLength - CorrectPos)
FreeMemory(*MemoryID)
CloseFile(#OutFile)
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
CloseFile(#InFile)
EndIf
EndIf
MessageRequester("GVI 2 DivX", "The Program Execution Has Finished")