Is there a JAVA API for extract MP4 Metadata

前端 未结 2 1261
野的像风
野的像风 2020-12-16 07:25

I want to be specific as to what I am asking. I am not asking to modified any MP4 files, just extract metadata such as Width and Height and bitrate and encoding and this is

相关标签:
2条回答
  • 2020-12-16 08:12

    At present (2015), Android SDK provides MediaMetadataRetriever class for extracting metadata:

            MediaMetadataRetriever m = new MediaMetadataRetriever();
            m.setDataSource(mInputFile);
            String extractedHeight = m.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT);
            String extractedWidth = m.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH);
    
    0 讨论(0)
  • 2020-12-16 08:23

    I actually found what I was looking for using Mp4Parser

    here is a simple lines of code to get what I wanted using Mp4Parser

    FileChannel fc = new FileInputStream("content/Video_720p_Madagascar-3.mp4").getChannel();
    IsoFile isoFile = new IsoFile(fc);
    MovieBox moov = isoFile.getMovieBox();
    for(Box b : moov.getBoxes()) {
        System.out.println(b);
    }
    

    b contains all the info I needed, now I just have to parse b to get exactly what I want.

    0 讨论(0)
提交回复
热议问题