1. 阿里云视频截取

1.1 根据时间截取

在oss地址后加上 ?x-oss-process=video/snapshot,t_4000,f_jpg,w_240,h_135,m_fast
其中t_4000表示截取的视频时间,截取4秒的画面, 单位为毫秒, w_240表示宽为240, h_135表示宽为135

 if (videoAddress == null) {
            throw new ProjectExeption("500","视频地址为空");
        }
        String landscapeSuffix = "?x-oss-process=video/snapshot,t_4000,f_jpg,w_240,h_135,m_fast";
        String portraitSuffix = "?x-oss-process=video/snapshot,t_4000,f_jpg,w_220,h_390,m_fast";
        Map<String, String> map = new HashMap<>();
        String surfacePicLandscape = videoAddress + landscapeSuffix;
        String surfacePicPortrait = videoAddress + portraitSuffix;
        map.put("surfacePicLandscape", surfacePicLandscape);
        map.put("surfacePicPortrait", surfacePicPortrait);
        return map;

2. 阿里云图片截取大小

oss地址后面加上 ?x-oss-process=image/resize,m_lfit,w_400
w_400,为宽, 高可不写, 它会自动匹配一个合适的高

smallPictureAddress = pictureAdd+"?x-oss-process=image/resize,m_lfit,w_400";
                        pictureAdd += "?x-oss-process=image/resize,m_lfit,w_1080";
                        roomCartypePictures.setSmallPictureAddress(smallPictureAddress);
                        roomCartypePictures.setPictureAdd(pictureAdd);
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐