Click here to Skip to main content
15,895,256 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Howdy

What 's the best way to add a header to an existing file if the file size is around 1-2GB

C++
Posted

1-2GB. Source? In one file? :WTF:

I think you have bigger things to worry about than adding anything, even a header, to that file...
 
Share this answer
 
Comments
mbue 3-Apr-11 6:54am    
The op didnt talk about a c-file. this could be a mp3 file or somthing else. The mp3 header (version1) is appended to the end of the file (i.e.).
Regards.
Du Sijun 3-Apr-11 6:57am    
Oh, It's raw PCM, and I would like to add a wave header to it.
OriginalGriff 3-Apr-11 7:09am    
AFAIK, PCM does not have a header, and adding a WAV header block will not make it a .WAV file! PCM is raw, uncompressed samples - Wav is compressed and block oriented.
I suspect you need to run it though a converter, or write your own.

Out of interest, just what audio are you using that is *that* big?
Albert Holguin 3-Apr-11 12:00pm    
actually, the wav header specifies the format, including pcm
OriginalGriff 3-Apr-11 15:56pm    
I learnt something new - Thank you!
You can do it like mp3 (v1) files do: append a fixed size header at the end of the file.
Otherwise like mp3v2-header you have to move all content of the file to make room for the header. mp3v2 reserves some extra space for changes. Thats why you must not move all the content again for minor changes in your header.
Regards.
 
Share this answer
 
Comments
Du Sijun 3-Apr-11 10:21am    
Sounds good, I will ask them reserve more spaces for me.
the problem with adding the wav header to a file this big is that any player will attempt to load the entire file to memory when playing it, completely bogging down a computer, what I would suggest is first breaking up the file into fixed size blocks (lets say 256MB, with the last file containing whatever data's left) and then add the header to each file individually... after all that, you can create a playlist to playback the audio continuously
 
Share this answer
 
Comments
OriginalGriff 3-Apr-11 15:54pm    
Definitely gets my 5. Propose as solution!
Albert Holguin 3-Apr-11 17:04pm    
thanks!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900