Open AndroidDeveloperLB opened 5 years ago
This is an old question, but hopefully it helps someone.
You can read/write metadata like this:
for(int i=0; i<video.getTracks().size();i++){
Track videoTrack = video.getTracks().get(i);
if(videoTrack.getHandler().equals("vide")){
TrackMetaData metaData = videoTrack.getTrackMetaData();
//Read Metadata
double width = metaData.getWidth();
double height = metaData.getHeight();
//Write Metadata
metaData.setHeight(yourDouble);
metaData.setWidth(yourDouble);
}
}
video
is referring to Movie video = MovieCreator.build(new FileDataSourceViaHeapImpl(filePath));
.
what about custom metadata?
@HBiSoft What about metadata that exists in general, instead of in some points in the video/audio file? Also, does this work for audio files too?
please create a sample or documentation to write a custom metadata on existing file @sannies 🙏
i found this file btw: https://raw.githubusercontent.com/sannies/mp4parser/ff137905f8f7334c3013fa5fa461a438de49c7e1/examples/src/main/java/org/mp4parser/examples/metadata/MetaDataInsert.java
I've seen this repository showing how to do it using the mp4parser repository (meaning here).
It works, but it uses an old version of the library ('com.googlecode.mp4parser:isoparser:1.1.22' instead of 'org.mp4parser:isoparser:1.9.37' ) . When updating to it, it doesn't work anymore (either doesn't read, or doesn't write) .
Is this really the best way to add and read metadata? Isn't there a better way? What's the official way to add and read metadata from an audio/video file? Which file formats are supported? Isn't there an API for this on Android itself?