ffmpeg java 使用教程_Java使用ffmpeg
首先完成基本的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 "+targetPath);
System.out.println("結束");
long end = System.currentTimeMillis();
System.out.println("轉化結束"+(end-start));
p.getOutputStream().close();
p.getInputStream().close();
p.getErrorStream().close();
p.waitFor();
return true;
}catch (Exception e){
e.printStackTrace();
return false;
}finally {
run.freeMemory();
}
}
}
Java操作ffmpeg優秀博客
ffmpeg一些命令
博客借鑒
ffmfeg
總結
以上是生活随笔為你收集整理的ffmpeg java 使用教程_Java使用ffmpeg的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 推荐一个下载简历模板的网站工具
- 下一篇: 大额支付系统