demultiplexing UBB2 videos [script]

Codecs, formats, encoding/decoding of game audio, video and music
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

demultiplexing UBB2 videos [script]

Post by AlphaTwentyThree »

Hi everybody,

I've finally finished my script that can demultiplex .ubb videos a.k.a. hnm. Those were used in Mega Race for example. It's a bit messy because of the different fields that can be contained in these videos.

Code: Select all

# demultiplex ubb/hnm videos
# script by AlphaTwentyThree for QuickBMS http://quickbms.aluigi.org

idstring "UBB2"
set OFFSET 0x44
get FSIZE asize
putvarchr MEMORY_FILE FSIZE 0
putvarchr MEMORY_FILE2 FSIZE 0
putvarchr MEMORY_FILE3 FSIZE 0
putvarchr MEMORY_FILE4 FSIZE 0
putvarchr MEMORY_FILE5 FSIZE 0
putvarchr MEMORY_FILE6 FSIZE 0
putvarchr MEMORY_FILE7 FSIZE 0
putvarchr MEMORY_FILE8 FSIZE 0
log MEMORY_FILE 0 0
log MEMORY_FILE2 0 0
log MEMORY_FILE3 0 0
log MEMORY_FILE4 0 0
log MEMORY_FILE5 0 0
log MEMORY_FILE6 0 0
log MEMORY_FILE7 0 0
log MEMORY_FILE8 0 0

for i = 1 #<= 100
   goto OFFSET
   get SIZE long
   getDstring IDENT 2
   #print "%IDENT% at %OFFSET%"
   get DUMMY short
   savepos OFFSET
   math SIZE -= 8
   if IDENT == "SD"
      append
      log MEMORY_FILE OFFSET SIZE
      append
      math OFFSET += SIZE
   elif IDENT == "PL"
      append
      log MEMORY_FILE2 OFFSET SIZE
      append
      math OFFSET += SIZE
   elif IDENT == "IV"
      append
      log MEMORY_FILE3 OFFSET SIZE
      append
      math OFFSET += SIZE
   elif IDENT == "DD"
      append
      log MEMORY_FILE4 OFFSET SIZE
      append
      math OFFSET += SIZE
   elif IDENT == "IZ"
      append
      log MEMORY_FILE5 OFFSET SIZE
      append
      math OFFSET += SIZE
   elif IDENT == "IU"
      append
      log MEMORY_FILE6 OFFSET SIZE
      append
      math OFFSET += SIZE
   elif IDENT == "TR"
      append
      log MEMORY_FILE7 OFFSET SIZE
      append
      math OFFSET += SIZE
   elif IDENT == "ZB"
      append
      log MEMORY_FILE8 OFFSET SIZE
      append
      math OFFSET += SIZE
   else # block size wrong -> go again
      math OFFSET -= 4
   endif
   if OFFSET >= FSIZE
      break
   endif
   xmath TEST "OFFSET + 4"
   if TEST >= FSIZE
      break
   endif
next i

get SIZE asize MEMORY_FILE
if SIZE > 0
   get NAME basename
   string NAME += ".sd"
   log NAME 0 SIZE MEMORY_FILE
endif
get SIZE asize MEMORY_FILE2
if SIZE > 0
   get NAME basename
   string NAME += ".pl"
   log NAME 0 SIZE MEMORY_FILE2
endif
get SIZE asize MEMORY_FILE3
if SIZE > 0
   get NAME basename
   string NAME += ".iv"
   log NAME 0 SIZE MEMORY_FILE3
endif
get SIZE asize MEMORY_FILE4
if SIZE > 0
   get NAME basename
   string NAME += ".dd"
   log NAME 0 SIZE MEMORY_FILE4
endif
get SIZE asize MEMORY_FILE5
if SIZE > 0
   get NAME basename
   string NAME += ".iz"
   log NAME 0 SIZE MEMORY_FILE5
endif
get SIZE asize MEMORY_FILE6
if SIZE > 0
   get NAME basename
   string NAME += ".iu"
   log NAME 0 SIZE MEMORY_FILE6
endif
get SIZE asize MEMORY_FILE7
if SIZE > 0
   get NAME basename
   string NAME += ".tr"
   log NAME 0 SIZE MEMORY_FILE7
endif
get SIZE asize MEMORY_FILE8
if SIZE > 0
   get NAME basename
   string NAME += ".zb"
   log NAME 0 SIZE MEMORY_FILE8
endif