java ffmpeg格式转换

package com.example.demo.util;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * ffmpeg格式转换
 */
public class ConvertVideoUtil {
    private static String inputPath = "";
    private static String outputPath = "";

    /**
     * ffmpeg安装所在目录的bin目录,如果是linux同理
     */
    private static String ffmpegPath = "";

    public static void main(String[] args) {
        getPath();
        if (!checkfile(inputPath)) {
            System.out.println(inputPath + " is not file");
            return;
        }
        if (process()) {
            System.out.println("ok");
        }
    }

    public static void getPath() {
        // 先获取当前项目路径,在获得源文件、目标文件、转换器的路径
        File diretory = new File("");
        try {
            String currPath = diretory.getAbsolutePath();
            inputPath = "D:\\ffmpeg\\Apple Watch~2.mp4";
            outputPath = "D:\\ffmpeg\\oss\\";
            ffmpegPath = "D:\\dev_tools\\ffmpeg\\ffmpeg-4.2.1-win64-static\\bin\\";
            System.out.println(currPath);
        } catch (Exception e) {
            System.out.println("getPath出错");
        }
    }

    public static boolean process() {
        int type = checkContentType();
        boolean status = false;
        //System.out.println("直接转成mp4格式");
        //status = processMp4(inputPath);// 直接转成mp4格式
        //processAVI(type);
        status = processTs(inputPath);// 直接转成mp4格式
        return status;
    }

    private static int checkContentType() {
        String type = inputPath.substring(inputPath.lastIndexOf(".") + 1, inputPath.le

你可能感兴趣的:(java,java,格式转换,ffmpeg)