public class Mp4TagWriter
extends java.lang.Object
|--- ftyp |--- free |--- moov |......| |......|----- mvdh |......|----- trak |......|----- udta |..............| |..............|-- meta |....................| |....................|-- hdlr |....................|-- ilst |....................|.. ..| |....................|.....|---- @nam (Optional for each metadatafield) |....................|.....|.......|-- data |....................|.....|....... ecetera |....................|.....|---- ---- (Optional for reverse dns field) |....................|.............|-- mean |....................|.............|-- name |....................|.............|-- data |....................|................ ecetere |....................|-- free |--- free |--- mdat
Modifier and Type | Field and Description |
---|---|
static java.util.logging.Logger |
logger |
private Mp4TagCreator |
tc |
Constructor and Description |
---|
Mp4TagWriter() |
Modifier and Type | Method and Description |
---|---|
private void |
adjustSizeOfMoovHeader(Mp4BoxHeader moovHeader,
java.nio.ByteBuffer moovBuffer,
int sizeAdjustment,
Mp4BoxHeader udtaHeader,
Mp4BoxHeader metaHeader)
When the size of the metadata has changed and it cant be compensated for by free atom
we have to adjust the size of the size field upto the moovheader level for the udta atom and
its child meta atom.
|
private void |
checkFileWrittenCorrectly(java.io.RandomAccessFile rafTemp,
Mp4BoxHeader mdatHeader,
java.nio.channels.FileChannel fileWriteChannel,
Mp4StcoBox stco)
Check File Written Correctly
|
private void |
convertandWriteTagsAtomToFreeAtom(java.nio.channels.FileChannel fileWriteChannel,
Mp4BoxHeader tagsHeader)
Replace tags atom (and children) by a free atom
|
private void |
createMetadataAtoms(Mp4BoxHeader moovHeader,
java.nio.ByteBuffer moovBuffer,
int sizeAdjustment,
Mp4BoxHeader udtaHeader,
Mp4BoxHeader metaHeader) |
void |
delete(java.io.RandomAccessFile raf,
java.io.RandomAccessFile rafTemp)
Delete the tag
|
private int |
getMetaLevelFreeAtomSize(Mp4AtomTree atomTree)
Determine the size of the free atom immediately after ilst atom at the same level (if any), we can use this if
ilst needs to grow or shrink because of more less metadata
|
void |
write(Tag tag,
java.io.RandomAccessFile raf,
java.io.RandomAccessFile rafTemp)
Write tag to rafTemp file
|
private void |
writeDataAfterIlst(java.nio.channels.FileChannel fileReadChannel,
java.nio.channels.FileChannel fileWriteChannel,
Mp4BoxHeader tagsHeader)
Write data after ilst upto the end of the file
|
private void |
writeDataInChunks(java.nio.channels.FileChannel fileReadChannel,
java.nio.channels.FileChannel fileWriteChannel)
#385 Write data in chunks, needed if writing large amounts of data
|
private void |
writeDataUptoIncludingIlst(java.nio.channels.FileChannel fileReadChannel,
java.nio.channels.FileChannel fileWriteChannel,
int oldIlstSize,
int startIlstWithinFile,
java.nio.ByteBuffer rawIlstData)
Write the data including new ilst
|
private void |
writeMetadataSameSize(java.nio.ByteBuffer rawIlstData,
long oldIlstSize,
long startIstWithinFile,
java.nio.channels.FileChannel fileReadChannel,
java.nio.channels.FileChannel fileWriteChannel,
Mp4BoxHeader tagsHeader)
Replace the ilst metadata
Because it is the same size as the original data nothing else has to be modified
|
private void |
writeNeroData(java.nio.channels.FileChannel fileReadChannel,
java.nio.channels.FileChannel fileWriteChannel,
Mp4BoxHeader tagsHeader)
If the existing files contains a tags atom and chp1 atom underneath the meta atom that means the file was
encoded by Nero.
|
public static java.util.logging.Logger logger
private Mp4TagCreator tc
private void writeMetadataSameSize(java.nio.ByteBuffer rawIlstData, long oldIlstSize, long startIstWithinFile, java.nio.channels.FileChannel fileReadChannel, java.nio.channels.FileChannel fileWriteChannel, Mp4BoxHeader tagsHeader) throws CannotWriteException, java.io.IOException
rawIlstData
- oldIlstSize
- startIstWithinFile
- fileReadChannel
- fileWriteChannel
- CannotWriteException
java.io.IOException
private void writeNeroData(java.nio.channels.FileChannel fileReadChannel, java.nio.channels.FileChannel fileWriteChannel, Mp4BoxHeader tagsHeader) throws java.io.IOException, CannotWriteException
fileReadChannel
- fileWriteChannel
- tagsHeader
- java.io.IOException
CannotWriteException
private void adjustSizeOfMoovHeader(Mp4BoxHeader moovHeader, java.nio.ByteBuffer moovBuffer, int sizeAdjustment, Mp4BoxHeader udtaHeader, Mp4BoxHeader metaHeader) throws java.io.IOException
moovHeader
- moovBuffer
- sizeAdjustment
- can be negative or positive *udtaHeader
- metaHeader
- java.io.IOException
private void createMetadataAtoms(Mp4BoxHeader moovHeader, java.nio.ByteBuffer moovBuffer, int sizeAdjustment, Mp4BoxHeader udtaHeader, Mp4BoxHeader metaHeader) throws java.io.IOException
java.io.IOException
public void write(Tag tag, java.io.RandomAccessFile raf, java.io.RandomAccessFile rafTemp) throws CannotWriteException, java.io.IOException
tag
- tag dataraf
- current filerafTemp
- temporary file for writingCannotWriteException
java.io.IOException
private void writeDataInChunks(java.nio.channels.FileChannel fileReadChannel, java.nio.channels.FileChannel fileWriteChannel) throws java.io.IOException, CannotWriteException
fileReadChannel
- fileWriteChannel
- java.io.IOException
CannotWriteException
private void convertandWriteTagsAtomToFreeAtom(java.nio.channels.FileChannel fileWriteChannel, Mp4BoxHeader tagsHeader) throws java.io.IOException
fileWriteChannel
- tagsHeader
- java.io.IOException
private void writeDataUptoIncludingIlst(java.nio.channels.FileChannel fileReadChannel, java.nio.channels.FileChannel fileWriteChannel, int oldIlstSize, int startIlstWithinFile, java.nio.ByteBuffer rawIlstData) throws java.io.IOException
can be used as long as we dont have to adjust the size of moov header
fileReadChannel
- fileWriteChannel
- oldIlstSize
- startIlstWithinFile
- rawIlstData
- java.io.IOException
private void writeDataAfterIlst(java.nio.channels.FileChannel fileReadChannel, java.nio.channels.FileChannel fileWriteChannel, Mp4BoxHeader tagsHeader) throws java.io.IOException, CannotWriteException
Can be used if dont need to adjust size of moov header of modify top level free atoms
fileReadChannel
- fileWriteChannel
- tagsHeader
- java.io.IOException
CannotWriteException
private int getMetaLevelFreeAtomSize(Mp4AtomTree atomTree)
atomTree
- private void checkFileWrittenCorrectly(java.io.RandomAccessFile rafTemp, Mp4BoxHeader mdatHeader, java.nio.channels.FileChannel fileWriteChannel, Mp4StcoBox stco) throws CannotWriteException, java.io.IOException
rafTemp
- mdatHeader
- fileWriteChannel
- stco
- CannotWriteException
java.io.IOException
public void delete(java.io.RandomAccessFile raf, java.io.RandomAccessFile rafTemp) throws java.io.IOException
This is achieved by writing an empty ilst atom
raf
- rafTemp
- java.io.IOException
Copyright © 2005-2013 java.net. All Rights Reserved.