linux 上java调用ffmpeg转码只有几秒长
1个回答
展开全部
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.io.*;
import java.lang.*;
import java.util.*;
import java.text.*;
import java.net.*;
public class Test {
public static void main(String[] args) {
List<String> commend = new ArrayList<String>();
commend.add("/usr/local/ffmpeg2/bin/./ffmpeg");
commend.add("-i");
commend.add("/opt/spzh/yysp.avi");
commend.add("-ab");
commend.add("128");
commend.add("-acodec");
commend.add("libfaac");
commend.add("-ac");
commend.add("1");
commend.add("-ar");
commend.add("22050");
commend.add("-r");
commend.add("24");
commend.add("-y");
commend.add("/opt/spzh/out/yysp18.flv");
StringBuffer test=new StringBuffer();
for(int i=0;i<commend.size();i++)
test.append(commend.get(i)+" ");
System.out.println(test);
try {
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(test.toString());
InputStream stderr = proc.getErrorStream();
InputStreamReader isr = new InputStreamReader(stderr);
BufferedReader br = new BufferedReader(isr);
String line = null;
while ( (line = br.readLine()) != null);
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("视频转换成功");
}
}
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.io.*;
import java.lang.*;
import java.util.*;
import java.text.*;
import java.net.*;
public class Test {
public static void main(String[] args) {
List<String> commend = new ArrayList<String>();
commend.add("/usr/local/ffmpeg2/bin/./ffmpeg");
commend.add("-i");
commend.add("/opt/spzh/yysp.avi");
commend.add("-ab");
commend.add("128");
commend.add("-acodec");
commend.add("libfaac");
commend.add("-ac");
commend.add("1");
commend.add("-ar");
commend.add("22050");
commend.add("-r");
commend.add("24");
commend.add("-y");
commend.add("/opt/spzh/out/yysp18.flv");
StringBuffer test=new StringBuffer();
for(int i=0;i<commend.size();i++)
test.append(commend.get(i)+" ");
System.out.println(test);
try {
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(test.toString());
InputStream stderr = proc.getErrorStream();
InputStreamReader isr = new InputStreamReader(stderr);
BufferedReader br = new BufferedReader(isr);
String line = null;
while ( (line = br.readLine()) != null);
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("视频转换成功");
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |