0

I can use grep to manipulate the output of all applications i use (or do something with sed or other tools). This doesn't work with FFmpeg. This is the output when i convert an audio file:

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%

I have to redirect the output from stderr to stdout (2>&1) so that grep works. But this doesn't work with the last line where i can see the progress of the process. With

ffmpeg ... 2>&1 | grep "size="

there is no output. I guess ffmpeg isn't using the stderr or stdout for that line?

3
  • 1
    Or it just doesn't output some information when the output isn't going to a TTY (some tools do output more information, or in a prettier format, when it's to a TTY - commonly so for progress information)
    – muru
    Commented Jan 21 at 11:32
  • 1
    Firstly I cannot reproduce the error on zsh and ffmpeg 6.1 with ffmpeg -f lavfi -i "sine=frequency=200:duration=10" out.flac 2>&1 | grep "size=" [out#0/flac @ 0xab5d2140] video:0kB audio:116kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 6.971678% . Secondly you can get some help from this unix.stackexchange.com/q/3514/407294 Commented Jan 21 at 13:16
  • 2
    Check if your ffmpeg command produces anything when you redirect it (ffmpeg ... 2>&1 | cat).
    – aviro
    Commented Jan 21 at 14:21

1 Answer 1

2

Sorry for being late to the show, but the way I do it is FFREPORT.

FFREPORT=file=$HOME/ffreport.log:level=99 ffmpeg ... 

Then you can:
grep ... ~/ffreport.log or cat ~/ffreport.log | grep ...

This is the only way, I know of, that's possible.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .