栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

2021SC@SDUSC-multimedia-utils-一款java后端的图片、视频处理工具jar包

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

2021SC@SDUSC-multimedia-utils-一款java后端的图片、视频处理工具jar包

2021SC@SDUSC 

目录

项目名称:multimedia-utils

CompressionAttributes

演示表格

VideoAttributes

 演示表格


项目名称:multimedia-utils

博客六

上篇博客我们介绍了视频工具FFmpegUtils,并且给出了详细的代码注释。下面我们将分析其他代码部分,首先来看的就是Java对音视频进行转码和处理部分。

CompressionAttributes

这部分就是前期处理。简单的设置音视频压缩参数以及得到压缩完成后的回调地址。下面我们用表格举例。

演示表格
参数类型必需注释
videoAttributesVideoAttributes视频压缩参数
audioAttributesAudioAttributes音频压缩参数
progressUrlString压缩完成后的回调地址
package com.whty.zdxt.multimedia.attribute;


public class CompressionAttributes {
    
    private AudioAttributes audioAttributes;

    
    private VideoAttributes videoAttributes;

    
    private String progressUrl;

    public CompressionAttributes() {
    }

    public CompressionAttributes(VideoAttributes videoAttributes, String progressUrl) {
        this.videoAttributes = videoAttributes;
        this.progressUrl = progressUrl;
    }

    public CompressionAttributes(AudioAttributes audioAttributes, String progressUrl) {
        this.audioAttributes = audioAttributes;
        this.progressUrl = progressUrl;
    }

    public CompressionAttributes(AudioAttributes audioAttributes, VideoAttributes videoAttributes, String progressUrl) {
        this.audioAttributes = audioAttributes;
        this.videoAttributes = videoAttributes;
        this.progressUrl = progressUrl;
    }

    public AudioAttributes getAudioAttributes() {
        return audioAttributes;
    }

    public void setAudioAttributes(AudioAttributes audioAttributes) {
        this.audioAttributes = audioAttributes;
    }

    public VideoAttributes getVideoAttributes() {
        return videoAttributes;
    }

    public void setVideoAttributes(VideoAttributes videoAttributes) {
        this.videoAttributes = videoAttributes;
    }

    public String getProgressUrl() {
        return progressUrl;
    }

    public void setProgressUrl(String progressUrl) {
        this.progressUrl = progressUrl;
    }

    @Override
    public String toString() {
        return "CompressionAttributes [" +
                "audioAttributes=" + audioAttributes +
                ", videoAttributes=" + videoAttributes +
                ", progressUrl=" + progressUrl +
                ']';
    }
}


VideoAttributes

 首先就是获取视频编码。再做接下来的处理。比如设置压缩后最大帧率 (未设置则保持同原视频一致),压缩后最大比特率。可以设置输出视频分辨率 (未设置则保持同原视频一致)。还可以设置压缩视频最大时长 (未设置则保持同原视频一致)。我们用下面的表格举例。

 演示表格
参数类型必需注释
codecVideoCodec视频编码(默认libx264,libx265)
maxFpsInteger最大帧率
videoSizeVideoSize视频分辨率(hd480,hd720,hd1080,800x800)
maxDurationInteger最大时长
maxBitRateInteger视频最大比特率

 代码部分

package com.whty.zdxt.multimedia.attribute;

import com.whty.zdxt.multimedia.enumeration.VideoCodec;
import com.whty.zdxt.multimedia.enumeration.VideoSize;

public class VideoAttributes {

    
    private VideoCodec codec;

    
    private Integer maxFps;

    
    private Integer maxBitRate;

    
    private VideoSize videoSize;

    
    private Integer maxDuration;


    public VideoCodec getCodec() {
        return codec;
    }

    public void setCodec(VideoCodec codec) {
        this.codec = codec;
    }

    public Integer getMaxFps() {
        return maxFps;
    }

    public void setMaxFps(Integer maxFps) {
        this.maxFps = maxFps;
    }

    public Integer getMaxBitRate() {
        return maxBitRate;
    }

    public void setMaxBitRate(Integer maxBitRate) {
        this.maxBitRate = maxBitRate;
    }

    public VideoSize getVideoSize() {
        return videoSize;
    }

    public void setVideoSize(VideoSize videoSize) {
        this.videoSize = videoSize;
    }

    public Integer getMaxDuration() {
        return maxDuration;
    }

    public void setMaxDuration(Integer maxDuration) {
        this.maxDuration = maxDuration;
    }

    @Override
    public String toString() {
        return "VideoAttributes [" +
                "codec=" + codec +
                ", maxFps=" + maxFps +
                ", maxBitRate=" + maxBitRate +
                ", videoSize=" + videoSize +
                ", maxDuration=" + maxDuration +
                ']';
    }
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/434419.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号