2011-06-14 2 views
2

Java Media Framework를 사용하여 비디오 파일을 재생하고 있습니다.Java Media Framework : 비디오 스트림에서 프레임 속도를 얻는 방법

이제 비디오 스트림의 프레임 속도를 알고 싶습니다.

어떻게 가능합니까? 감사!

편집 : 다음의 인스턴스를 사용할 수 있습니다

javax.media.Manager 
javax.media.MediaLocator 
javax.media.NoProcessorException 
javax.media.Processor 
+0

을, 우리가 할 수있을 것입니다 확실 해요 도와주세요. –

+0

JMF를 사용하지 마십시오. 와이드 카메라를 지원하지 않습니다. 거의 작동하지 않지만 생산 수준에서는 악몽으로 고생 할 것입니다. – YumYumYum

답변

3

 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) { 
     } 

혹은 컨텐츠 기술자가 데이터 소스를 형성 형성 다음 해보십시오. 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()); 
     } 
    } 
} 
+2

좋은 코딩. 그러나 JMF를 사용하지 마십시오. Oracle은 이에 대한 개발을 중단합니다. – YumYumYum

관련 문제