0

Why doesn't this command line work:

vim <(ffmpeg -i vid.mp4 2>&1)

I'd expect it to have identical behaviour to the (working)

vim <(ffprobe -i vid.mp4 2>&1)

But actually the ffmpeg version just clears my screen (I'm assuming bc vim/ncurses is started) and causes my terminal to freeze, completely unresponsive to everything ctrl-c ctrl-d and ctrl-z. There is a blinking cursor in top-left. I have to quit that terminal window/tab after running this command line

cat <(ffmpeg -i vid.mp4 2>&1)

also never completes, it just outputs some of what is expected, then freezes


expected behaviour:

since ffmpeg has this output normally

$ ffmpeg -i vid.mp4
ffmpeg version 4.3.2 Copyright (c) 2000-2021 the FFmpeg developers
  built with Apple clang version 12.0.0 (clang-1200.0.32.29)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.2_4 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 00:01:05.59, start: 0.000000, bitrate: 1668 kb/s
    Stream #0:0(und): Video: h264 (High 10) (avc1 / 0x31637661), yuv420p10le, 1920x1080 [SAR 1:1 DAR 16:9], 1532 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(jpn): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
At least one output file must be specified

I would expect vim <(ffmpeg -i vid.mp4 2>&1) to open a buffer with contents

ffmpeg version 4.3.2 Copyright (c) 2000-2021 the FFmpeg developers
  built with Apple clang version 12.0.0 (clang-1200.0.32.29)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.2_4 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 00:01:05.59, start: 0.000000, bitrate: 1668 kb/s
    Stream #0:0(und): Video: h264 (High 10) (avc1 / 0x31637661), yuv420p10le, 1920x1080 [SAR 1:1 DAR 16:9], 1532 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(jpn): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
At least one output file must be specified
4
  • I'm not sure why exactly this happens but the two commands are not the same FWIW. ffmpeg converts video/audio files where ffprobe just prints information about the file. Your ffmpeg command isn't even a valid command as it complains that there is no specified output file.
    – jesse_b
    Commented Apr 22, 2021 at 21:46
  • Also, even if ffmpeg output was valid media data, by mixing in stderr (2>&1), you're essentially producing garbage.
    – muru
    Commented Apr 23, 2021 at 1:37
  • @muru if I understood you correctly, then the garbage is what I want to produce. Please see my edit
    – minseong
    Commented Apr 23, 2021 at 10:51
  • @jesse_b why does ffmpeg not terminate when inside a process substitution? "Your ffmpeg command isn't even a valid command" well, it terminates when it's not in a process substitution, even with helpful error printing. Seems to be good
    – minseong
    Commented Apr 23, 2021 at 10:51

1 Answer 1

3

ffmpeg opens standard input for interactive usage by default. From the docs:

-stdin

Enable interaction on standard input. On by default unless standard input is used as an input. To explicitly disable interaction you need to specify -nostdin.

Disabling interaction on standard input is useful, for example, if ffmpeg is in the background process group. Roughly the same result can be achieved with ffmpeg ... < /dev/null but it requires a shell.

Vim, too, opens stdin for interactive usage, which is probably where the conflict happens. Using -nostdin or redirection for ffmpeg as mentioned above should work:

vim <(ffmpeg -i vid.mp4 -nostdin 2>&1)
vim <(ffmpeg -i vid.mp4 <&- 2>&1)
vim <(ffmpeg -i vid.mp4 </dev/null 2>&1)
2
  • why doesn't the ffmpeg -i vid.mp4 command have any special behaviour if it's "enabling interaction on stdin" ?
    – minseong
    Commented Apr 23, 2021 at 13:19
  • Probably because there's nothing interactive there. As it says, "on by default". They probably don't care enough to close it if it's not needed unless explicitly asked to.
    – muru
    Commented Apr 23, 2021 at 15:20

You must log in to answer this question.

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