首先完成基本的Java调用ffmpeg代码实现
package com.example.ffmpegtest01.service.impl;
import com.example.ffmpegtest01.service.OperationService;
import org.springframework.stereotype.Service;
import java.io.File;
@Service
public class OperationServiceImpl implements OperationService {
@Override
public Boolean ForAvi(String sourcePath, String targetPath) {//sourcePtah是对应的文件的路径
String webroot = "D:\\devsoft\\ffmpeg\\bin";
Runtime run= null;
System.out.println(new File(webroot).getAbsolutePath());
try{
run = Runtime.getRuntime();
long start = System.currentTimeMillis();
//File diretory = new File("");
System.out.println("开始");
Process p = run.exec(new File(webroot).getAbsolutePath()+"/ffmpeg -i "+sourcePath+" -codec copy "