【发布时间】:2015-09-24 16:21:51
【问题描述】:
我想读出一个用 ffmpeg 加载的视频文件的信息。 ffmpeg 在控制台中的输出:
[sebastian@ULBP2681 ~]$ ffmpeg -i /mnt/Speicherschwein/workspace/testVideos/00-50-C2-1D-7F-85_005.avi
ffmpeg version 2.7.1 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 5.1.0 (GCC)
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gnutls --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-shared --enable-version3 --enable-x11grab
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, avi, from '/mnt/Speicherschwein/workspace/testVideos/00-50-C2-1D-7F-85_005.avi':
Duration: 00:00:21.12, start: 0.000000, bitrate: 303 kb/s
Stream #0:0: Video: h264 (High) (H264 / 0x34363248), yuv420p, 512x512 [SAR 1:1 DAR 1:1], 268 kb/s, 50 fps, 50 tbr, 50 tbn, 50 tbc
我希望在 Duration 中拥有的信息。
所以现在我的问题: 我通过
运行ffmpegString command = "ffmpeg -i " + absolutePath;
Process processDuration = Runtime.getRuntime().exec(command);
我需要将控制台输出(不在控制台中打印输出)读出到 Sting 中。
我试图从 outputStream 中读取,但这似乎不起作用,因为 inputStream 不起作用。
谁能给我提示我如何读出通过 java Runtime.getRuntime().exec(command); 运行的进程的控制台输出?
【问题讨论】:
-
另请参阅When Runtime.exec() won't,了解有关正确创建和处理流程的许多好技巧。然后忽略它引用
exec并使用ProcessBuilder创建进程。
标签: java string ffmpeg console runtime.exec