尝试以下方法
try {
Processor myProcessor = Manager.createProcessor( myMediaLocator );
Format relax = myProcessor.getContentDescriptor().relax();
if(relax instanceof VideoFormat) {
double frameRate = ((VideoFormat)relax).getFrameRate();
}
} catch( NoProcessorException e ) {
} catch( NotConfiguredError e ) {
} catch( IOException e ) {
}或者可能从DataSource形成内容描述符。对于URLDataSource:
DataSource dataSource = myProcessor.getDataOutput();
if(dataSource instanceof URLDataSource){
PullSourceStream[] streams = ((URLDataSource)dataSource).getStreams();
if(streams.length > 0){
Format relax = streams[0].getContentDescriptor().relax();
if(relax instanceof VideoFormat) {
System.out.println(((VideoFormat)relax).getFrameRate());
}
}
}或者至少尝试从javax.media.Buffer获取格式:
DataSource dataSource = myProcessor.getDataOutput();
if(dataSource instanceof PullBufferDataSource){ // or PushBufferDataSource
PullBufferStream[] streams = ((PullBufferDataSource)dataSource).getStreams();
if(streams.length > 0){
Format relax = streams[0].getFormat();
if(relax instanceof VideoFormat) {
System.out.println(((VideoFormat)relax).getFrameRate());
}
}
}