跑步
/usr/bin/mediainfo --Inform='Video;%Duration%' /home/daniel/upload/videos/4/f/6/e/f/4f6ef2e0d67c4.flv
从终端给我这个输出
903520
并在java中运行它
Process p1;
try {
p1 = Runtime.getRuntime().exec("/usr/bin/mediainfo --Inform='Video;%Duration%' /home/daniel/upload/videos/4/f/6/e/f/4f6ef2e0d67c4.flv");
BufferedReader input1 = new BufferedReader(new InputStreamReader(p1.getInputStream()));
String line1;
while ((line1 = input1.readLine()) != null) {
System.out.println("-"+line1);
}
input1.close();
p1.waitFor();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
结果是
-General
-Complete name : /home/daniel/upload/videos/4/f/6/e/f/4f6ef2e0d67c4.flv
-Format : Flash Video
-File size : 62.0 MiB
-Duration : 15mn 3s
-Overall bit rate : 576 Kbps
-Tagging application : Yet Another Metadata Injector for FLV - Version 1.4
-
-Video
-Format : AVC
-Format/Info : Advanced Video Codec
-Format profile : High@L2.0
-Format settings, CABAC : Yes
-Format settings, ReFrames : 4 frames
-Codec ID : 7
-Duration : 15mn 3s
-Bit rate : 512 Kbps
(much more here) ...
如何从 Runtime.getRuntime().exec(cmd) 获得我想要的输出(903520)?
编辑:固定格式