이 mp3 SPI support을 사용하여 MP3 파일을 처리 할 수 있지만 mp4 파일과 비슷한 것을 찾지 못했습니다.mp4 파일 용 Java API가 있습니까?
도움을 주시면 감사하겠습니다.
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));
다음
--answer
대답입니다 : 내가 원하는 무엇
--update
은이 코드를 사용하여 웨이브 파일과 마찬가지로, 파일의 크기를 얻을 수있다 @mdma의 힌트를 사용하여 코드 (IBM 툴킷) :
/**
* 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;
}
-
관련, 언어 독립적 질문 : Anyone familiar with mp4 data structure?
mp4parser 프로젝트에는 svn 또는 다운로드가 없습니다. JMF + Jffmpeg로 시도하고 있습니다 만, 힘들어합니다. –
@Tom - mp4parser 소스가 있습니다. - http://mp4parser.googlecode.com/svn/trunk/에서 소스를 체크 아웃했습니다. – mdma
@TomBrito 정말 노력하고 있습니다 만,이 프로젝트는 너무 가난합니다. –