wisherzhang / mp4v2

Automatically exported from code.google.com/p/mp4v2
Other
0 stars 0 forks source link

write a file without reading it #97

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Currently MP4Modify and MP4File::Modify make it difficult if not impossible to 
write to a file without reading it first.  Consider this workflow:

1. read a file
2. modify it
3. write the changes back

This is possible today, but I believe only if the file stays open the entire 
time.  I think it would be an improvement if we could:

a. open the file read-only
b. read it
c. close the file
d. modify the info in memory
e. open the file read-write
f. write the file
g. close the file

I'm curious what people think of this.  It'll take me awhile to come up with a 
patch for this but it's on my list.

Original issue reported on code.google.com by dbyr...@gmail.com on 19 Apr 2011 at 9:51

GoogleCodeExporter commented 8 years ago
In addition to MP4Modify/Mp4File::Modify, the generic itmf interface is also 
not suited for this.  Specifically, MP4ItmfAddItem, MP4ItmfSetItem and 
MP4ItmfRemoveItem all take an MP4FileHandle which I believe also means the file 
in question must be open.  If there was a way to operate on the data structures 
and then later, "tie" them to a particular MP4FileHandle, I think I could do 
what I have in mind.

Original comment by dbyr...@gmail.com on 20 Apr 2011 at 4:36

GoogleCodeExporter commented 8 years ago
One possibility is using a custom file provider.  So, to start with, you read 
the entire file into memory.  Then use a custom file provider that can read 
from that memory buffer, modify things, etc.  Then when you're done, write out 
that buffer to memory.

I've thought about doing a custom file provider based on Qt, since they have a 
number of primitives that would make in-memory stuff pretty easy (e.g. 
QByteArray is a pretty solid fit).

Original comment by kid...@gmail.com on 27 Apr 2011 at 7:00