I hope it's not too late, but if you want to add / edit / delete metadata fields in MP4 files, you can use the JCodec metadata editing classes.
There is a CLI tool supported by the java API. The CLI is in org.jcodec.movtool.MetadataEditorMain , and the API is in org.jcodec.movtool.MetadataEditor .
More on this: http://jcodec.org/docs/working_with_mp4_metadata.html
So basically, when you want to add some metadata, you need to know which key (s) corresponds to it. One way to find out is to check out a sample file that already contains the necessary metadata. To do this, you can run the JCodec CLI tool, which will simply print all existing metadata fields (keys with values):
./metaedit <file.mp4>
Then, when you know the key you want to work with, you can use the same CLI tool:
or the same through the Java API:
MetadataEditor mediaMeta = MetadataEditor.createFrom(new File("file.mp4")); Map<Integer, MetaValue> meta = mediaMeta.getItunesMeta(); meta.put(0xa9415254, MetaValue.createString("New value")); // fourcc for '©ART' mediaMeta.save(false); // fast mode is off
To remove a metadata field from a file:
MetadataEditor mediaMeta = MetadataEditor.createFrom(new File("file.mp4")); Map<Integer, MetaValue> meta = mediaMeta.getItunesMeta(); meta.remove(0xa9415254); // removes the '©ART' mediaMeta.save(false); // fast mode is off
To convert a string to an integer fourcc, you can use something like:
byte[] bytes = "©ART".getBytes("iso8859-1"); int fourcc = ByteBuffer.wrap(bytes).order(ByteOrder.BIG_ENDIAN).getInt();
If you want to edit / delete Android metadata, you will need to use a different set of fucntion (because it is stored differently than iTunes metadata):
./metaedit -sk com.android.capture.fps,float=25.0 file.mp4
OR, alternatively, via the API:
MetadataEditor mediaMeta = MetadataEditor.createFrom(new File("file.mp4")); Map<String, MetaValue> meta = mediaMeta.getKeyedMeta(); meta.put("com.android.capture.fps", MetaValue.createFloat(25.)); mediaMeta.save(false);