Need for Speed Underground .MAD Video File

Codecs, formats, encoding/decoding of game audio, video and music
WillWNTD
Posts: 13
Joined: Mon Mar 14, 2022 7:12 pm

Need for Speed Underground .MAD Video File

Post by WillWNTD »

Does anyone know any tools or ways to convert .mad videos to a more common format such as .avi or .mp4 and then convert them back to .mad?

I would like to edit these videos and make them work in game. Thanks in advance.

I attached a sample file, if anyone can take a look I'd appreciate it.
WillWNTD
Posts: 13
Joined: Mon Mar 14, 2022 7:12 pm

Re: Need for Speed Underground .MAD Video File

Post by WillWNTD »

I found that it is possible to convert .mad to .mp4 with VLC, but the video has no sound. To extract the audio in .wav, you need to use EA Conv 06i.

Does anyone know a way to convert the audio and video back to .mad format? Thanks.
BloodRaynare
Posts: 367
Joined: Fri Mar 10, 2017 7:23 am

Re: Need for Speed Underground .MAD Video File

Post by BloodRaynare »

Though the format has a documentation (you can find it at here), unfortunately none of MAD encoder exists outside the EA tools, which obviously only the EA devs has them. But at least you can remux/demux the mad files (Which means you can't create new videos, but you can replace/extract the audio), so there something.

Here's a rough BMS script created by me to deal with the mad files

Demux:

Code: Select all

log MEMORY_FILE 0 0
log MEMORY_FILE2 0 0

get MAD_ORIG_SIZE asize

append
for i = 0
   get ID long
   savepos CHUNK_CURRPOS
   get CHUNK_SIZE long
   math CHUNK_CURRPOS - 4
   if ID != 0x6b44414d && ID != 0x6d44414d && ID != 0x6544414d
      log MEMORY_FILE2 CHUNK_CURRPOS CHUNK_SIZE
   else
      log MEMORY_FILE CHUNK_CURRPOS CHUNK_SIZE
   endif
   math CHUNK_CURRPOS + CHUNK_SIZE
   if CHUNK_CURRPOS >= MAD_ORIG_SIZE
      break
   else
      goto CHUNK_CURRPOS
   endif
next i
append

get MAD_SIZE asize MEMORY_FILE
get ASF_SIZE asize MEMORY_FILE2
log TMP.MAD 0 MAD_SIZE MEMORY_FILE
log TMP.ASF 0 ASF_SIZE MEMORY_FILE2



Remux:

Code: Select all

open FDDE ASF
open FDDE MAD 1

log MEMORY_FILE 0 0

get STR_SIZE asize
get UV_SIZE asize 1

append
for i = 0
   savepos CURR_CHUNK_POS_2 1
   get ID long 1
   get CHUNK_SIZE_2 long 1
   log MEMORY_FILE CURR_CHUNK_POS_2 CHUNK_SIZE_2 1
   savepos CURR_CHUNK_POS
   get ID long
   get CHUNK_SIZE long
   log MEMORY_FILE CURR_CHUNK_POS CHUNK_SIZE
   math CURR_CHUNK_POS + CHUNK_SIZE
   math CURR_CHUNK_POS_2 + CHUNK_SIZE_2
   if CURR_CHUNK_POS >= STR_SIZE
      break
   else
      goto CURR_CHUNK_POS
   endif
   if CURR_CHUNK_POS_2 >= UV_SIZE
      for j = 0
         savepos CURR_CHUNK_POS
         get ID long
         get CHUNK_SIZE long
         log MEMORY_FILE CURR_CHUNK_POS CHUNK_SIZE
         math CURR_CHUNK_POS + CHUNK_SIZE
         if CURR_CHUNK_POS >= STR_SIZE
            break
         else
            goto CURR_CHUNK_POS
         endif
      next j
      break
   else
      goto CURR_CHUNK_POS_2 1
   endif
next i
append

get TGQ_SIZE asize MEMORY_FILE
log TMP_.MAD 0 TGQ_SIZE MEMORY_FILE


Well obviously the audio replacement must be encoded with the EA STR/ASF format (with EA XA v2 codec), using EA's SX (Sound eXchange) tools which was already available on the net.
WillWNTD
Posts: 13
Joined: Mon Mar 14, 2022 7:12 pm

Re: Need for Speed Underground .MAD Video File

Post by WillWNTD »

I was hoping there would be a way to re-encode the video to .mad, but thank you very much for replying me and for the audio script! I'll test it later.
gledson999
Posts: 11
Joined: Fri Jan 27, 2017 1:07 pm

Re: Need for Speed Underground .MAD Video File

Post by gledson999 »

It's possible mux and demux MPC videos from NFS U2, MW for PS2?
BloodRaynare
Posts: 367
Joined: Fri Mar 10, 2017 7:23 am

Re: Need for Speed Underground .MAD Video File

Post by BloodRaynare »

gledson999 wrote:It's possible mux and demux MPC videos from NFS U2, MW for PS2?


Yes it's possible actually, I've written these rough BMS scripts to demonstrate it.

Demux (Or you can use VGMToolbox's demuxer ones, it's doing pretty much same thing as this script actually):

Code: Select all

log MEMORY_FILE 0 0
log MEMORY_FILE2 0 0

get FNAME basename

get MPC_ORIG_SIZE asize

append
for i = 0
   get ID long
   savepos CHUNK_CURRPOS
   get CHUNK_SIZE long
   math CHUNK_CURRPOS - 4
   if ID != 0x6843504d
      log MEMORY_FILE2 CHUNK_CURRPOS CHUNK_SIZE
   else
      log MEMORY_FILE CHUNK_CURRPOS CHUNK_SIZE
   endif
   math CHUNK_CURRPOS + CHUNK_SIZE
   if CHUNK_CURRPOS >= MPC_ORIG_SIZE
      break
   else
      goto CHUNK_CURRPOS
   endif
next i
append

get MPC_SIZE asize MEMORY_FILE
get ASF_SIZE asize MEMORY_FILE2

string VNAME p "%s.video.mpc" FNAME
string ANAME p "%s.audio.asf" FNAME

log VNAME 0 MPC_SIZE MEMORY_FILE
log ANAME 0 ASF_SIZE MEMORY_FILE2



Mux:

Code: Select all

get FNAME basename

string FNAME -> 6

string VNAME p "%s.video.mpc" FNAME
string ANAME p "%s.audio.asf" FNAME

open FDSE VNAME
open FDSE ANAME 1

log MEMORY_FILE 0 0

get MPC_SIZE asize
get STR_SIZE asize 1

append
for i = 0
   savepos CURR_CHUNK_POS
   get ID long
   get CHUNK_SIZE long
   log MEMORY_FILE CURR_CHUNK_POS CHUNK_SIZE
   savepos CURR_CHUNK_POS_2 1
   get ID long 1
   get CHUNK_SIZE_2 long 1
   log MEMORY_FILE CURR_CHUNK_POS_2 CHUNK_SIZE_2 1
   math CURR_CHUNK_POS + CHUNK_SIZE
   math CURR_CHUNK_POS_2 + CHUNK_SIZE_2
   
   if CURR_CHUNK_POS >= MPC_SIZE
      for j = 0
         get ID long 1
         get CHUNK_SIZE_2 long 1
         log MEMORY_FILE CURR_CHUNK_POS_2 CHUNK_SIZE_2 1
         math CURR_CHUNK_POS_2 + CHUNK_SIZE_2
         if CURR_CHUNK_POS_2 >= STR_SIZE
            break
         else
            goto CURR_CHUNK_POS_2 1
         endif
      next j
      break
   else
      goto CURR_CHUNK_POS
   endif
   
   if CURR_CHUNK_POS_2 >= STR_SIZE
      for j = 0
         get ID long
         get CHUNK_SIZE long
         log MEMORY_FILE CURR_CHUNK_POS CHUNK_SIZE
         math CURR_CHUNK_POS + CHUNK_SIZE
         if CURR_CHUNK_POS >= MPC_SIZE
            break
         else
            goto CURR_CHUNK_POS
         endif
      next j
      break
   else
      goto CURR_CHUNK_POS_2 1
   endif
next i
append

get MPC_SIZE asize MEMORY_FILE
string VMNAME p "%s.mpc" FNAME
log VMNAME 0 MPC_SIZE MEMORY_FILE


Note for Mux: It's only working for the already existing demuxed MPC file ATM, for creating the MPC video stream from scratch would require to study where the per frame data ends, but other than that it's pretty simple actually.
YAGAMI55
Posts: 55
Joined: Sun May 24, 2020 9:16 pm

Re: Need for Speed Underground .MAD Video File

Post by YAGAMI55 »

actually, possible create new .MPC

all you need is oledebug and pss downsample
YAGAMI55
Posts: 55
Joined: Sun May 24, 2020 9:16 pm

Re: Need for Speed Underground .MAD Video File

Post by YAGAMI55 »

Here is video instruction to CREATE YOUR OWN .MPC

Just make new .m2v with the same params as original from demuxing

and the sound file encoded by sx.exe with the same params as original from demuxing


https://mega.nz/file/lGgTiIzR#RDuAmss9- ... 9k5YrwSz4c