admin管理员组文章数量:1630387
直接进入正题吧。
ps:利用ffmpeg 来进行格式转换。
一 建立 java项目。
二 在所建立的java项目中 建立一个ffmpeg文件夹,这个文件夹下放ffmpeg所需的文件。
三 在建立一个 input文件,这个文件是用来存放视频文件,例如xxx.rmvb.
四 在建立一个output文件,这个文件时用来存放你想转换后的视频文件。(例如你想把xxx.rmvb转换成xxx.mp4)
五 之后就是写 java代码。
package com;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
public class ConvertVideo {
private static String inputPath = "";
private static String outputPath = "";
private static String ffmpegPath = "";
public static void main(String args[]) throws IOException {
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 = "E:\\1.mp4";
outputPath = "D:\\vod\\oss\\";
ffmpegPath = "E:\\ffmpeg1\\";
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格式
版权声明:本文标题:java 实现 视频格式转换。 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1729070151a1184952.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论