windows系统需要下载ffmpeg软件,并在代码中指定路径
centos系统需要安装ffmepg是可执行的命令
package com.xkj.utils;import lombok.extern.slf4j.Slf4j;import java.io.*;
import java.util.ArrayList;
import java.util.List;@Slf4j
public class ConvertVideoUtils {//需要转码的视频的全地址private String inputPath;//转码后文件的目录private String outputPath;//ffmpeg文件的路径,linux下无需配置private String ffmpegPath;//转码后文件的名称private String fileName;public ConvertVideoUtils(String inputPath, String outputPath, String ffmpegPath, String fileName) {log.info("开始转码.....");log.info("inputPath={}", inputPath);log.info("outputPath={}", outputPath);log.info("fileName={}", fileName);log.info("ffmpegPath={}", ffmpegPath);this.inputPath = inputPath;this.outputPath = outputPath;this.ffmpegPath = ffmpegPath;this.fileName = fileName;}public static boolean process(String inputPath, String ffmpegPath, String outputPath, String fileName) {int type = checkContentType(inputPath);boolean status = false;log.info("直接转成mp4格式");status = processMp4(inputPath, ffmpegPath, outp