|
@@ -1,141 +0,0 @@
|
|
-//package org.jeecg.modules.demo.opencv;
|
|
|
|
-//
|
|
|
|
-//import java.io.BufferedReader;
|
|
|
|
-//import java.io.IOException;
|
|
|
|
-//import java.io.InputStream;
|
|
|
|
-//import java.io.InputStreamReader;
|
|
|
|
-//import java.text.SimpleDateFormat;
|
|
|
|
-//import java.util.ArrayList;
|
|
|
|
-//import java.util.Date;
|
|
|
|
-//import java.util.List;
|
|
|
|
-//import java.util.UUID;
|
|
|
|
-//
|
|
|
|
-//public class FFmpegUtils {
|
|
|
|
-// public static void videoToPcm(String vedioUrl,String m4aUrl,String ffmpegUrl) throws InterruptedException, IOException {
|
|
|
|
-// List<String> commend = new ArrayList<String>();
|
|
|
|
-// commend.add(ffmpegUrl);
|
|
|
|
-// commend.add("-i");
|
|
|
|
-// commend.add(vedioUrl);
|
|
|
|
-// commend.add("-vn");
|
|
|
|
-// commend.add("y");
|
|
|
|
-// commend.add("-acodec");
|
|
|
|
-// commend.add("copy");
|
|
|
|
-// commend.add(m4aUrl);
|
|
|
|
-// ProcessBuilder builder = new ProcessBuilder();
|
|
|
|
-// builder.command(commend);
|
|
|
|
-// builder.redirectErrorStream(true);
|
|
|
|
-// Process process = builder.start();
|
|
|
|
-// process.waitFor();// 等待进程执行结束
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// public static void mergeVideodioAndPcm(String videoInputPath, String audioInputPath, String videoOutPath,String ffmpegUrl) throws InterruptedException, IOException {
|
|
|
|
-// /**
|
|
|
|
-// * String command = FFMPEG_PATH + " -i " + videoInputPath + " -i " + audioInputPath
|
|
|
|
-// * + " -c:v copy -c:a aac -strict experimental " +
|
|
|
|
-// * " -map 0:v:0 -map 1:a:0 "
|
|
|
|
-// * + " -y " + videoOutPath;
|
|
|
|
-// */
|
|
|
|
-// List<String> commend = new ArrayList<String>();
|
|
|
|
-// commend.add(ffmpegUrl);
|
|
|
|
-// commend.add("-i");
|
|
|
|
-// commend.add(videoInputPath);
|
|
|
|
-// commend.add("-i");
|
|
|
|
-// commend.add(audioInputPath);
|
|
|
|
-// commend.add(" -c:v");
|
|
|
|
-// commend.add("copy");
|
|
|
|
-// commend.add("-c:a");
|
|
|
|
-// commend.add("acc");
|
|
|
|
-// commend.add("-strict");
|
|
|
|
-// commend.add("experimental");
|
|
|
|
-// commend.add(videoOutPath);
|
|
|
|
-// ProcessBuilder builder = new ProcessBuilder();
|
|
|
|
-// builder.command(commend);
|
|
|
|
-// builder.redirectErrorStream(true);
|
|
|
|
-// Process process = builder.start();
|
|
|
|
-// process.waitFor();// 等待进程执行结束
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// public static void main(String[] args) throws InterruptedException, IOException {
|
|
|
|
-//// videoToPcm("D:\\data\\fill.mp4","D:\\data\\fill.m4a","D:\\java\\ffmpeg\\bin\\ffmpeg.exe");
|
|
|
|
-//// mergeVideodioAndPcm("D:\\data\\merge.mp4","D:\\data\\fill.m4a","D:\\data\\fill2.mp4","D:\\java\\ffmpeg\\bin\\ffmpeg.exe");
|
|
|
|
-// try {
|
|
|
|
-// videoToAudio("D:\\data\\test\\fill.mp4","D:\\data\\test\\123.mp3");
|
|
|
|
-// String videoInputPath = "D:\\data\\test\\merge.mp4";
|
|
|
|
-// String audioInputPath = "D:\\data\\test\\123.mp3";
|
|
|
|
-// String videoOutPath = "D:\\data\\test\\fill.mp4";
|
|
|
|
-// convetor(videoInputPath,audioInputPath,videoOutPath);
|
|
|
|
-// } catch (Exception e) {
|
|
|
|
-// e.printStackTrace();
|
|
|
|
-// }
|
|
|
|
-// System.out.println("---------获取音频文件成功!-----------");
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// /**
|
|
|
|
-// * @param videoInputPath 原视频的全路径
|
|
|
|
-// * @param audioInputPath 音频的全路径
|
|
|
|
-// * @param videoOutPath 视频与音频结合之后的视频的路径
|
|
|
|
-// * @throws Exception
|
|
|
|
-// */
|
|
|
|
-// public static void convetor(String videoInputPath, String audioInputPath, String videoOutPath)
|
|
|
|
-// throws Exception {
|
|
|
|
-// Process process = null;
|
|
|
|
-// try {
|
|
|
|
-// String command =FFMPEG_PATH + " -i " + videoInputPath + " -i " + audioInputPath + " -c:v copy -c:a aac -strict experimental " +
|
|
|
|
-// " -map 0:v:0 -map 1:a:0 "
|
|
|
|
-// + " -y " + videoOutPath;
|
|
|
|
-// System.out.println(command);
|
|
|
|
-// process = Runtime.getRuntime().exec(command);
|
|
|
|
-// process.waitFor();
|
|
|
|
-// } catch (IOException e) {
|
|
|
|
-// // TODO Auto-generated catch block
|
|
|
|
-// e.printStackTrace();
|
|
|
|
-// }
|
|
|
|
-// // 使用这种方式会在瞬间大量消耗CPU和内存等系统资源,所以这里我们需要对流进行处理
|
|
|
|
-// InputStream errorStream = process.getErrorStream();
|
|
|
|
-// InputStreamReader inputStreamReader = new InputStreamReader(errorStream);
|
|
|
|
-// BufferedReader br = new BufferedReader(inputStreamReader);
|
|
|
|
-//
|
|
|
|
-// String line = "";
|
|
|
|
-// while ((line = br.readLine()) != null) {
|
|
|
|
-// }
|
|
|
|
-// if (br != null) {
|
|
|
|
-// br.close();
|
|
|
|
-// }
|
|
|
|
-// if (inputStreamReader != null) {
|
|
|
|
-// inputStreamReader.close();
|
|
|
|
-// }
|
|
|
|
-// if (errorStream != null) {
|
|
|
|
-// errorStream.close();
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// /**
|
|
|
|
-// * 从视频中提取音频信息
|
|
|
|
-// * @param videoUrl
|
|
|
|
-// * @return
|
|
|
|
-// */
|
|
|
|
-// public static String videoToAudio(String videoUrl,String accFile){
|
|
|
|
-// String aacFile = "";
|
|
|
|
-// try {
|
|
|
|
-// aacFile = TMP_PATH + "/" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())
|
|
|
|
-// + UUID.randomUUID().toString().replaceAll("-", "") + ".mp3";
|
|
|
|
-// String command = FFMPEG_PATH + " -i "+ videoUrl + " -vn -acodec copy "+ aacFile;
|
|
|
|
-// System.out.println("video to audio command : " + command);
|
|
|
|
-// Process process = Runtime.getRuntime().exec(command);
|
|
|
|
-// process.waitFor();
|
|
|
|
-// } catch (Exception e) {
|
|
|
|
-// e.printStackTrace();
|
|
|
|
-// }
|
|
|
|
-// return "";
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// /**
|
|
|
|
-// * FFmpeg全路径
|
|
|
|
-// */
|
|
|
|
-// private static final String FFMPEG_PATH = "D:\\java\\ffmpeg\\bin\\ffmpeg.exe";
|
|
|
|
-// /**
|
|
|
|
-// * 音频保存路径
|
|
|
|
-// */
|
|
|
|
-// private static final String TMP_PATH = "D:\\data\\test";
|
|
|
|
-//}
|
|
|