我可以使用 grep 来操作我使用的所有应用程序的输出(或使用 sed 或其他工具执行某些操作)。这不适用于 FFmpeg。这是我转换音频文件时的输出:
ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
[dts @ 0x564229946680] Estimating duration from bitrate, this may be inaccurate
Input #0, dts, from '/home/user/testfile.dts':
Duration: 01:08:20.10, start: 0.000000, bitrate: 1535 kb/s
Stream #0:0: Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s
File '/home/user/testfile.flac' already exists. Overwrite? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (dts (dca) -> flac (native))
Press [q] to stop, [?] for help
[flac @ 0x56422994c300] encoding as 24 bits-per-sample
Output #0, flac, to '/home/user/testfile.flac':
Metadata:
encoder : Lavf58.76.100
Stream #0:0: Audio: flac, 48000 Hz, 5.1(side), s32 (24 bit), 128 kb/s
Metadata:
encoder : Lavc58.134.100 flac
size= 70537kB time=00:03:04.89 bitrate=3125.2kbits/s speed= 101x
video:0kB audio:70529kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.011476%
我必须将输出从 stderr 重定向到 stdout (2>&1) 以便 grep 工作。但这不适用于我可以看到该过程进度的最后一行。和
ffmpeg ... 2>&1 | grep "size="
没有输出。我猜 ffmpeg 没有为该行使用 stderr 或 stdout ?