Changing AVI-meta-data with RIFF Services

Windows specific forum
harff182
Enthusiast
Enthusiast
Posts: 105
Joined: Thu Dec 08, 2005 4:58 pm
Location: Duesseldorf, Germany

Changing AVI-meta-data with RIFF Services

Post by harff182 »

moin, moin...

Like ID3V2 for MP3, there are RIFF-INFO-Tags for AVIs.

My attempts to read them succeded with this code:

Code: Select all

Define main_lpck.MMCKINFO
Define info_lpck.MMCKINFO
Define Itag_lpck.MMCKINFO

Define Itag_buff.s =Space(1024)

Define filename.s = "NASA.avi"
;Filename.s = OpenFileRequester("","","AVI Files (*.avi)|*.avi",0)

If Filename
   HMMIO = mmioOpen_(Filename,0,#MMIO_READ)
   
   ; check FILE FORMAT
   main_lpck\fccType = mmioStringToFOURCC_("AVI ",MMIO_TOUPPER)
   
   Result = mmioDescend_(HMMIO,main_lpck,0,#MMIO_FINDRIFF)
   
   If Result <> #MMSYSERR_NOERROR
      Debug "Error:  Not an AVI file!" : End
   Else
      Debug "Suxes:  This is an AVI file!"
   EndIf
   
   ; find in LIST named INFO 
   info_lpck\fccType= mmioStringToFOURCC_("INFO",MMIO_TOUPPER)  
   Result = mmioDescend_(HMMIO,info_lpck,0,#MMIO_FINDLIST)
   
   If Result <> #MMSYSERR_NOERROR     
      Debug "Error:  Couldn't get the LIST named INFO!"
   Else
      Debug "Suxes:  Found the LIST named INFO"
   EndIf
   
   Debug info_lpck\ckid
   Debug PeekS(@info_lpck\ckid,4)

   Debug info_lpck\cksize

   Debug info_lpck\fccType
   Debug PeekS(@info_lpck\fccType,4)

   Debug info_lpck\dwDataOffset
   Debug info_lpck\dwFlags
   
  
   ; find the existing chunk(tag) "INAM"
   Itag_lpck\ckid   = mmioStringToFOURCC_("INAM",MMIO_TOUPPER)
      
   Result = mmioDescend_(HMMIO,Itag_lpck,info_lpck,#MMIO_FINDCHUNK)
   
   If Result <> #MMSYSERR_NOERROR     
      Debug "Error:  Couldn't get the CHUNK named INAM !"
   Else
      Debug "Suxes:  Found the CHUNK named INAM"
   EndIf  
   
   Debug Itag_lpck\ckid
   Debug PeekS(@Itag_lpck\ckid,4)

   Debug Itag_lpck\cksize

   Debug Itag_lpck\fccType
   Debug PeekS(@Itag_lpck\fccType,4)

   Debug Itag_lpck\dwDataOffset
   Debug Itag_lpck\dwFlags 
   
  Debug "--read the value of INAM-------------------------"
  result = mmioRead_(HMMIO,Itag_buff,Itag_lpck\ckSize)
  Debug result 
  Debug Itag_buff
   
  mmioClose_(HMMIO,0)
   
EndIf
Next I tried to change the value of an existing tag, but this code fails:

Code: Select all

Define main_lpck.MMCKINFO
Define info_lpck.MMCKINFO
Define Itag_lpck.MMCKINFO

Define Itag_buff.s =Space(1024)
Define write_buf.s =Space(1024)

Define filename.s = "NASA.avi"
;Filename.s = OpenFileRequester("","","AVI Files (*.avi)|*.avi",0)

If Filename
   HMMIO = mmioOpen_(Filename,0,#MMIO_READ)
   
   ; check FILE FORMAT
   main_lpck\fccType = mmioStringToFOURCC_("AVI ",MMIO_TOUPPER)
   
   Result = mmioDescend_(HMMIO,main_lpck,0,#MMIO_FINDRIFF)
   
   If Result <> #MMSYSERR_NOERROR
      Debug "Error:  Not an AVI file!" : End
   Else
      Debug "Suxes:  This is an AVI file!"
   EndIf
   
   ; find in LIST named INFO 
   info_lpck\fccType= mmioStringToFOURCC_("INFO",MMIO_TOUPPER)  
   Result = mmioDescend_(HMMIO,info_lpck,0,#MMIO_FINDLIST)
   
   If Result <> #MMSYSERR_NOERROR     
      Debug "Error:  Couldn't get the LIST named INFO!"
   Else
      Debug "Suxes:  Found the LIST named INFO"
   EndIf
   
   Debug info_lpck\ckid
   Debug PeekS(@info_lpck\ckid,4)

   Debug info_lpck\cksize

   Debug info_lpck\fccType
   Debug PeekS(@info_lpck\fccType,4)

   Debug info_lpck\dwDataOffset
   Debug info_lpck\dwFlags
   
  
   ; find the existing chunk(tag) "INAM"
   Itag_lpck\ckid   = mmioStringToFOURCC_("INAM",MMIO_TOUPPER)
      
   Result = mmioDescend_(HMMIO,Itag_lpck,info_lpck,#MMIO_FINDCHUNK)
   
   If Result <> #MMSYSERR_NOERROR     
      Debug "Error:  Couldn't get the CHUNK named INAM !"
   Else
      Debug "Suxes:  Found the CHUNK named INAM"
   EndIf  
   
   Debug Itag_lpck\ckid
   Debug PeekS(@Itag_lpck\ckid,4)

   Debug Itag_lpck\cksize

   Debug Itag_lpck\fccType
   Debug PeekS(@Itag_lpck\fccType,4)

   Debug Itag_lpck\dwDataOffset
   Debug Itag_lpck\dwFlags 
   
  Debug "---------Try to change the contentes of INAM--------------"
  
  write_buf = "changed by me"
  
  wr_result = mmioWrite_(HMMIO,*write_buff,Len(write_buf))
  Debug wr_result
  
  
  Itag_lpck\dwFlags = #MMIO_DIRTY
  asc_result = mmioAscend_(HMMIO,Itag_lpck,0)
  
  If asc_result = MMIOERR_CANNOTSEEK
    Debug "MMIOERR_CANNOTSEEK:     There was an error while seekingto the end of the Chunk"
  ElseIf asc_result = MMIOERR_CANNOTWRITE
    Debug "MMIOERR_CANNOTWRITE:    The contents of the buffer could not be written to disk"
  Else
    Debug "unknown errorcode"
  EndIf
  
   
  mmioClose_(HMMIO,0)
   
EndIf
I have a completely tagged 240KB-video, that I can send for tests, if neccessary (sorry, I have no webspace to put it on).
Is anybody out here, who wants to waste some of his time and help me?

tia...
scholly
Sorry 4 my poor English, it's the only one I learned 40 years ago...
since 17.12.08: XPHome(SP3) + PB 4.30