写一段java,调用ffmpeg函数,拉取rtsp视频流并解析转码为264
时间: 2023-02-28 16:01:29 浏览: 140
public class VideoStream {
public static void main(String[] args) {
// 调用ffmpeg函数
String ffmpeg = "ffmpeg -i rtsp://xxx -f h264 -vcodec libx264 -acodec aac -strict -2 -y output.264";
try {
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(ffmpeg);
InputStream stderr = proc.getErrorStream();
InputStreamReader isr = new InputStreamReader(stderr);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null)
System.out.println(line);
int exitVal = proc.waitFor();
System.out.println("Process exitValue: " + exitVal);
} catch (Throwable t) {
t.printStackTrace();
}
}
}
阅读全文