Google Video (*.gvi) to DivX (*.divX) converter

Share your advanced PureBasic knowledge/code with the community.
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Google Video (*.gvi) to DivX (*.divX) converter

Post by fsw »

The subject should do it...

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")
fsw
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

What i do is find a movie on google that i want to download then i follow these steps:

1). Click the download link on the movie's page.
2). Open the downloaded *.gvp file in a text editor.
3). Copy the url listed in the file.
4). paste into a browser address bar and hit enter.
5). download full original movie with no google flash compression.

sometimes the downloaded movie has headers that are missing but it is otherwise ok. You can use SUPER to convert it to whatever format you like. :)
--Kale

Image
Post Reply