2021SC@SDUSC
目录
项目名称:multimedia-utils
博客十二
在上篇博客我们介绍的是runtimeutils文件。今天我们将介绍我们是如何获取音视频信息,并将修改好的音视频信息值返回的相关知识。
在解释相关代码之前,我们需要清楚一个视频或者音频有许多例如宽,高,duration等等常用信息。我们需要对这些相关信息进行获取。在这个项目中我们用的是相关info方法。例如我们使用的VideoInfo和AudioInfo和FFmpegInfo文件。用的方法一致。只不过是获取的对应参数不同。
AudioInfo
package com.whty.zdxt.multimedia.pojo;
public class AudioInfo {
// 音频 编码名称
private String codecName;
// 音频 audio
private String codecType;
// 音频 时长
private String duration;
// 音频 比特率
private Integer bitRate;
// 音频 采样率
private Integer sampleRate;
// 音频 声道数 1:单声道 2:双声道
private Integer channels;
public String getCodecName() {
return codecName;
}
public void setCodecName(String codecName) {
this.codecName = codecName;
}
public String getCodecType() {
return codecType;
}
public void setCodecType(String codecType) {
this.codecType = codecType;
}
public String getDuration() {
return duration;
}
public void setDuration(String duration) {
this.duration = duration;
}
public Integer getBitRate() {
return bitRate;
}
public void setBitRate(Integer bitRate) {
this.bitRate = bitRate;
}
public Integer getSampleRate() {
return sampleRate;
}
public void setSampleRate(Integer sampleRate) {
this.sampleRate = sampleRate;
}
public Integer getChannels() {
return channels;
}
public void setChannels(Integer channels) {
this.channels = channels;
}
@Override
public String toString() {
return "AudioInfo [" +
"codecName=" + codecName +
", codecType=" + codecType +
", duration=" + duration +
", bitRate=" + bitRate +
", sampleRate=" + sampleRate +
", channels=" + channels +
']';
}
}
VideoInfo
package com.whty.zdxt.multimedia.pojo;
public class VideoInfo {
// 视频 编码名称
private String codecName;
// 视频 video
private String codecType;
// 视频 宽度
private Integer width;
// 视频 高度
private Integer height;
// 视频 帧率
private Integer frameRate;
// 视频 时长
private String duration;
// 视频 比特率
private Integer bitRate;
// 视频 总帧数
private Integer nbFrames;
public String getCodecName() {
return codecName;
}
public void setCodecName(String codecName) {
this.codecName = codecName;
}
public String getCodecType() {
return codecType;
}
public void setCodecType(String codecType) {
this.codecType = codecType;
}
public Integer getWidth() {
return width;
}
public void setWidth(Integer width) {
this.width = width;
}
public Integer getHeight() {
return height;
}
public void setHeight(Integer height) {
this.height = height;
}
public Integer getFrameRate() {
return frameRate;
}
public void setFrameRate(Integer frameRate) {
this.frameRate = frameRate;
}
public String getDuration() {
return duration;
}
public void setDuration(String duration) {
this.duration = duration;
}
public Integer getBitRate() {
return bitRate;
}
public void setBitRate(Integer bitRate) {
this.bitRate = bitRate;
}
public Integer getNbFrames() {
return nbFrames;
}
public void setNbFrames(Integer nbFrames) {
this.nbFrames = nbFrames;
}
@Override
public String toString() {
return "VideoInfo [" +
"codecName=" + codecName +
", codecType=" + codecType +
", width=" + width +
", height=" + height +
", frameRate=" + frameRate +
", duration=" + duration +
", bitRate=" + bitRate +
", nbFrames=" + nbFrames +
']';
}
}
FFmpegInfo
package com.whty.zdxt.multimedia.pojo;
import java.util.List;
public class FFmpegInfo {
private List<FFStream> streams;
private FFFormat format;
private AudioInfo audioInfo;
private VideoInfo videoInfo;
public List<FFStream> getStreams() {
return streams;
}
public void setStreams(List<FFStream> streams) {
this.streams = streams;
}
public FFFormat getFormat() {
return format;
}
public void setFormat(FFFormat format) {
this.format = format;
}
public AudioInfo getAudioInfo() {
return audioInfo;
}
public void setAudioInfo(AudioInfo audioInfo) {
this.audioInfo = audioInfo;
}
public VideoInfo getVideoInfo() {
return videoInfo;
}
public void setVideoInfo(VideoInfo videoInfo) {
this.videoInfo = videoInfo;
}
@Override
public String toString() {
return "FFmpegInfo [" +
"streams=" + streams +
", format=" + format +
", audioInfo=" + audioInfo +
", videoInfo=" + videoInfo +
']';
}
}