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および他のライブラリは同じ結果を返します。
https://stackoverflow.com/a/14303137/6347620 – Mike