2017-11-08 12 views
0

私はこのビデオの幅コードがSamsung Galaxy s6とSamsung note 3の値を返したいと思っています。私は多くの異なるコードとライブラリをテストしましたが、結果は同じです。サムスン銀河S6で :640×480サムスンのノート3で :853x480 私はGspotプログラム、それは示してこのビデオを開いたとき:ビデオの幅はデバイスによって異なります

推奨ディスプレイサイズ:853x480

と、これが同じ値でありますiphone 7でテストされた私たちのIOSアプリから返されました。アスペクトラジオは同じではなく、これは大きな問題です。ここで

私がテストコードの一部である:

(1)

MediaMetadataRetriever metaRetriever = new MediaMetadataRetriever(); 
    metaRetriever.setDataSource(path); 
    Bitmap bmp = metaRetriever.getFrameAtTime(-1); 

    int height = bmp.getHeight(); 
    int width = bmp.getWidth(); 

(2)

MediaPlayer myMediaPlayer= MediaPlayer.create(ApplicationLoader.applicationContext, 
            Uri.fromFile(new File(path))); 

    width = myMediaPlayer.getVideoWidth(); 
    height = myMediaPlayer.getVideoHeight(); 

(3)

MediaMetadataRetriever metaRetriever = new MediaMetadataRetriever(); 
     metaRetriever.setDataSource(path); 
String heights = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT); 
     String widths = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH); 
    int height = Integer.valueOf(heights); 
     int width = Integer.valueOf(widths); 

(4)

MediaPlayer myMediaPlayer= MediaPlayer.create(ApplicationLoader.applicationContext, Uri.fromFile(new File(path))); 
      myMediaPlayer.setOnVideoSizeChangedListener((mp, width, height) -> { 
     int videoWidth = width; 
     int videoHeight = height; 
    ); 
      myMediaPlayer.setDataSource(path); 
      myMediaPlayer.prepare(); 

FFmpegMediaMetadataRetrieverFFmpeg JavaExoPlayerおよび他のライブラリは同じ結果を返します。

+0

https://stackoverflow.com/a/14303137/6347620 – Mike

答えて

0

デバイスのDPIスケールで画像を拡大しようとすると、元のピクセル幅が同じようにスケールされたプレマイドビットマップで同じ問題が発生しました。

関連する問題