[FFmpeg-user] Option -nostdin not working correctly?

Lars Kiesow lkiesow at uos.de
Fri Mar 24 19:44:48 EET 2017


Hi everyone,
I want to run FFmpeg as a background process. But if you run something
like the following command line, the process will bu suspended as long
as FFmpeg is in the background:

  $ ffmpeg -y -f lavfi -i testsrc=r=1 -t 300 out.mp4&
    ffmpeg version 3.1.7 Copyright (c) 2000-2017 the FFmpeg developers
    ...
    [1]+  Stopped       ffmpeg -y -f lavfi -i testsrc=r=1 -t 300 out.mp4
  $ ls -l out.mp4
    ls: cannot access 'out.mp4': No such file or directory

Only after using `fg` to get the process to the foreground, FFmpeg will
actually start the encoding.

I have tried using the `-nostdin` option to fix that as the
documentation states:

  -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.

But the option seems to have no effect, except for disabling the
keyboard controls:

  $ ffmpeg -nostdin -y -f lavfi -i testsrc=r=1 -t 300 out.mp4&
    ffmpeg version 3.1.7 Copyright (c) 2000-2017 the FFmpeg developers
    ...
    [1]+  Stopped  ffmpeg -nostdin -y -f lavfi -i ... out.mp4
  $ ls -l out.mp4
    ls: cannot access 'out.mp4': No such file or directory

What works id to pipe /dev/null into ffmpeg like this:

  $ ffmpeg -f lavfi -i testsrc=r=1 -t 300 out.mp4 < /dev/null &

The problem is that a shell is required for this and I do not want to
start FFmpeg from a shell but from another process. Again, I can attach
stdin to /dev/null in that subprocess call, but from how I interpret the
docs, that is what `-nostdin` should prevent.

Am I missing anything? Is that a bug in the current FFmpeg version?

Best regards,
Lars


More information about the ffmpeg-user mailing list