这是报的错误 转换avi等格式都正常,就是转换rmvb和rm格式报错,求帮助
G:\视频\mencoder.exe G:\视频\电视机高清测试视频短片.rmvb -oac mp3lame -lameopts preset=64 -ovc xvid -xvidencopts bitrate=600 -of avi -o G:\视频\转换\电视机高清测试视频短片.avi MEncoder Sherpya-MinGW-20060312-4.1.0 (C) 2000-2006 MPlayer Team CPU: Intel Pentium III Xeon Cascades (Family: 6, Stepping: 9) CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 0 SSE2: 0 Compiled for x86 CPU with extensions: MMX MMX2 3DNow 3DNowEx success: format: 0 data: 0x0 - 0x1e397b0 REAL file format detected. Stream description: Audio Stream Stream mimetype: audio/x-pn-realaudio Stream description: Video Stream Stream mimetype: video/x-pn-realvideo Stream mimetype: logical-fileinfo VIDEO: [RV40] 720x400 24bpp 29.000 fps 0.0 kbps ( 0.0 kbyte/s) [V] filefmt:11 fourcc:0x30345652 size:720x400 fps:29.00 ftime:=0.0345 ========================================================================== Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders AUDIO: 44100 Hz, 2 ch, s16le, 96.5 kbit/6.84% (ratio: 12058->176400) Selected audio codec: [ffcook] afm: ffmpeg (FFmpeg COOK audio decoder) ========================================================================== xvid: using library version 1.1.0 (build xvid-1.1.0) Opening video filter: [expand osd=1] Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1 ========================================================================== Opening video decoder: [realvid] RealVideo decoder Read the RealVideo section of the DOCS! VDecoder init failed :( Error loading dll Opening video decoder: [realvid] RealVideo decoder ERROR: Could not open required DirectShow codec drvc.so. Error loading dll Read the RealVideo section of the DOCS! ERROR: Could not open required DirectShow codec drv4.so.6.0. VDecoder init failed :( Opening video decoder: [realvid] RealVideo decoder Error loading dll Read the RealVideo section of the DOCS! ERROR: Could not open required DirectShow codec drv43260.dll. VDecoder init failed :( Opening video decoder: [realvid] RealVideo decoder Error loading dll Read the RealVideo section of the DOCS! ERROR: Could not open required DirectShow codec drvc.bundle/Contents/MacOS/drvc. VDecoder init failed :( Cannot find codec matching selected -vo and video format 0x30345652. Read DOCS/HTML/en/codecs.html! ========================================================================== Exiting... who cares --G:\视频\ffmpeg.exe -i G:\视频\转换\电视机高清测试视频短片.avi -ab 128 -acodec libmp3lame -ac 1 -ar 22050 -r 29.97 -qscale 6 -y G:\视频\转换\电视机高清测试视频短片.flv ok
这是源码
package com.sino.test;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
public class ChangeVideo {
public static void main(String[] args) {
ChangeVideo.convert("G:\视频\电视机高清测试视频短片.rmvb", "G:\视频\转换\电视机高清测试视频短片.flv");
}
/**
* @param inputFile:需要转换的视频
* @param outputFile:转换后的视频
* @return
*/
public static boolean convert(String inputFile, String outputFile) {
if (!checkfile(inputFile)) {
System.out.println(inputFile + " is not file");
return false;
}
if (process(inputFile, outputFile)) {
System.out.println("ok");
return true;
}
return false;
}
// 检查文件能否存在
private static boolean checkfile(String path) {
File file = new File(path);
if (!file.isFile()) {
return false;
}
return true;
}
/**
* @param inputFile
* @param outputFile
* @return
* 转换视频文件
*/
private static boolean process(String inputFile, String outputFile) {
int type = checkContentType(inputFile);
boolean status = false;
if (type == 0) {
status = processFLV(inputFile, outputFile);// 直接将文件转为flv文件
} else if (type == 1) {
System.out.println("是rmvb文件!!!");
String avifilepath = processAVI(type, inputFile);
if (avifilepath == null){
System.out.println("avi文件没有得到");
return false;// avi文件没有得到
}
status = processFLV(avifilepath, outputFile);// 将avi转为flv
}
return status;
}
private static int checkContentType(String inputFile) {
String type = inputFile.substring(inputFile.lastIndexOf(".") + 1,
inputFile.length()).toLowerCase();
// ffmpeg能解析的格式:(asx,asf,mpg,wmv,3gp,mp4,mov,avi,flv等)
if (type.equals("avi")) {
return 0;
} else if (type.equals("mpg")) {
return 0;
} else if (type.equals("wmv")) {
return 0;
} else if (type.equals("3gp")) {
return 0;
} else if (type.equals("mov")) {
return 0;
} else if (type.equals("mp4")) {
return 0;
} else if (type.equals("asf")) {
return 0;
} else if (type.equals("asx")) {
return 0;
} else if (type.equals("flv")) {
return 0;
}
// 对ffmpeg无法解析的文件格式(wmv9,rm,rmvb等),
// 可以先用别的工具(mencoder)转换为avi(ffmpeg能解析的)格式.
else if (type.equals("wmv9")) {
return 1;
} else if (type.equals("rm")) {
return 1;
} else if (type.equals("rmvb")) {
return 1;
}
return 9;
}
// ffmpeg能解析的格式:(asx,asf,mpg,wmv,3gp,mp4,mov,avi,flv等)直接转换为目标视频
private static boolean processFLV(String inputFile, String outputFile) {
if (!checkfile(inputFile)) {
System.out.println(inputFile + " is not file");
return false;
}
List<String> commend = new ArrayList<String>();
commend.add(Constants.ffmpegPath);
commend.add("-i");
commend.add(inputFile);
commend.add("-ab");
commend.add("128");
commend.add("-acodec");
commend.add("libmp3lame");
commend.add("-ac");
commend.add("1");
commend.add("-ar");
commend.add("22050");
commend.add("-r");
commend.add("29.97");
//高品质
commend.add("-qscale");
commend.add("6");
//低品质
// commend.add("-b");
// commend.add("512");
commend.add("-y");
commend.add(outputFile);
StringBuffer test = new StringBuffer();
for (int i = 0; i < commend.size(); i++) {
test.append(commend.get(i) + " ");
}
System.out.println("--"+test);
try {
ProcessBuilder builder = new ProcessBuilder();
builder.command(commend);
builder.start();
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
// 对ffmpeg无法解析的文件格式(wmv9,rm,rmvb等),
// 可以先用别的工具(mencoder)转换为avi(ffmpeg能解析的)格式.
private static String processAVI(int type, String inputFile) {
File file = new File(Constants.avifilepath);
if (file.exists())
file.delete();
List<String> commend = new ArrayList<String>();
commend.add(Constants.mencoderPath);
commend.add(inputFile);
commend.add("-oac");
commend.add("mp3lame");
commend.add("-lameopts");
commend.add("preset=64");
commend.add("-ovc");
commend.add("xvid");
commend.add("-xvidencopts");
commend.add("bitrate=600");
commend.add("-of");
commend.add("avi");
commend.add("-o");
commend.add(Constants.avifilepath);
StringBuffer test = new StringBuffer();
for (int i = 0; i < commend.size(); i++) {
test.append(commend.get(i) + " ");
}
System.out.println(test);
try {
ProcessBuilder builder = new ProcessBuilder();
builder.command(commend);
Process p = builder.start();
final InputStream is1 = p.getInputStream();
final InputStream is2 = p.getErrorStream();
new Thread() {
public void run() {
BufferedReader br = new BufferedReader(
new InputStreamReader(is1));
try {
String lineB = null;
while ((lineB = br.readLine()) != null) {
if (lineB != null)
System.out.println(lineB);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}.start();
new Thread() {
public void run() {
BufferedReader br2 = new BufferedReader(
new InputStreamReader(is2));
try {
String lineC = null;
while ((lineC = br2.readLine()) != null) {
if (lineC != null)
System.out.println(lineC);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}.start();
// 等Mencoder进程转换结束,再调用ffmepg进程
p.waitFor();
System.out.println("who cares");
return Constants.avifilepath;
} catch (Exception e) {
System.err.println(e);
return null;
}
}
}
package com.sino.test;
public class Constants {
//ffmpeg存放的路径
public static final String ffmpegPath = "G:\视频\ffmpeg.exe";
//mencoder存放的路径
public static final String mencoderPath = "G:\视频\mencoder.exe";
//通过mencoder转换成的avi存放路径
public static final String avifilepath = "G:\视频\转换\电视机高清测试视频短片.avi";
}
解决方案
10
不懂 只能帮顶
30
drvc.so、drv43260.dll这些库没有加载成功,先在Java之外测一下这个工具能不能用