Kernel.system doesn't ignore output
I have a small script that I run in WSL (Debian) on ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux-gnu].
It does a simple thing:
cmd = ['ffmpeg', '-hide_banner', '-loglevel', 'panic', '-i', "#{video_file}",
'-i', "#{audio_file}", '-c', 'copy', '-map', '0:v:0', '-map', '1:a:0', "#{output}"].join(' ')
@log.debug("Command: #{cmd}")
system(cmd) or raise 'It broke'
As far as I understand, this should cause Ruby to ignore all output from FFmpeg (even though there is supposed to be none), but what happened is FFmpeg was barfing output all over the terminal breaking things.
How is this possible?
I wanted a way to feed array to system() call, so I would specify actual command once as an array and then reuse it.
8 comments · 75% upvoted · other discussions
system()will send all output to stdout. You might want to passffmpegoptions to silence output, like-nostats -loglevel 0. Or you could useShellwords.shelljointo safely combine/escape the arguments into a singleStringthen append2>&1 >/dev/null.Gendalph [OP] 1 points · Oct 2022
Thank you.
-loglevelchanges based on verbosity argument and beer goes below fatal, but at some point, when script is running in a for cycle, it gets ignored completely by FFmpeg. I've printed out the command, interrupted the script, ran the command manually and FFmpeg ran silently.Regardless, this answers my question and I already use Open3 to run FFmpeg.