Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there a Java API for mp4 files?
    text
    copied!<p>Mp3 files can be handled using this <a href="http://www.javazoom.net/mp3spi/sources.html" rel="nofollow noreferrer">mp3 SPI support</a>, but I'm not finding something similar to mp4 files.</p> <p>Any help would be appreciated.</p> <p>--UPDATE</p> <p>What I want to do is get the file's size, as I do with wave files using this code:</p> <pre><code>AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(file); AudioFormat format = audioInputStream.getFormat(); long audioFileLength = file.length(); int frameSize = format.getFrameSize(); float frameRate = format.getFrameRate(); float durationInSeconds = (audioFileLength / (frameSize * frameRate)); </code></pre> <p>--ANSWER</p> <p>Here is the answer code using the hint of @mdma (IBM toolkit):</p> <pre><code>/** * Use IBMPlayerForMpeg4SDK to get mp4 file duration. * * @return the mp4File duration in milliseconds. */ public static long getMp4Duration(File mp4File) throws IllegalStateException, IOException { PlayerControl playerControl = PlayerFactory.createLightweightMPEG4Player(); playerControl.open(mp4File.getAbsolutePath()); long mili = playerControl.getDuration(); // int sec = (int) ((mili / 1000) % 60); // int min = (int) ((mili / 1000) / 60); // System.out.println("IBM Tookit result = " + min + ":" + sec); return mili; } </code></pre> <p>--</p> <p>Related, language independent, question: <a href="https://stackoverflow.com/questions/3057157/anyone-familiar-with-mp4-data-structure">Anyone familiar with mp4 data structure?</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload