简体   繁体   English

不同设备的视频宽度不同

[英]Video width is different in different devices

I have a special video when i want to get this video's width code returns different value for Samsung galaxy s6 and Samsung note 3. I tested many different codes and libraries, but result is the same. 当我想获取此视频的宽度代码为Samsung galaxy s6和Samsung note 3返回不同的值时,我有一个特殊的视频。我测试了许多不同的代码和库,但是结果是相同的。 in Samsung galaxy s6: 640x480 in Samsung note 3: 853x480 when I open this video with Gspot program it shows: 在三星银河s6中:在三星笔记3中为640x480:当我使用Gspot程序打开此视频时,显示为853x480:

Recommended Display Size: 853x480 推荐的显示尺寸:853x480

and this is the same value is returned by our IOS app tested in Iphone 7. aspect radio is not the same and this is big problem. 这与我们在Iphone 7中测试过的IOS应用返回的值相同。方面无线电不一样,这是个大问题。

here is some of codes I tested: 这是我测试过的一些代码:

(1) (1)

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

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

(2) (2)

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

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

(3) (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) (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();

FFmpegMediaMetadataRetriever , FFmpeg Java , ExoPlayer and some other libraries returns the same result. FFmpegMediaMetadataRetrieverFFmpeg JavaExoPlayer和其他一些库返回相同的结果。

尝试用设备的DPI比例缩放图像,我对预制位图有同样的问题,原来的像素宽度是这样缩放的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM