os.system('ffmpeg -ss 00:08:00 -i '+dAdi+' -frames:v 1 /home/pi/Desktop/filmekrangoruntuleri/'+egAdi+'2.jpg')

When I run my python(3) script through the terminal, I see the following outputs produced by ffmpeg, but how do I do this without appearing?

ffmpeg version 3.2.10-1~deb9u1+rpt2 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1+deb9u1) 20170516
  configuration: --prefix=/usr --extra-version='1~deb9u1+rpt2' --toolchain=hardened --libdir=/usr/lib/arm-linux-gnueabihf --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx-rpi --enable-mmal --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --arch=armhf --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 34.101 / 55. 34.101
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.101 / 57. 56.101
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
Input #0, matroska,webm, from 'A.R.O.G.2008.m1080p.25fps.VP9.128kbit.AAC.mkv':
    ENCODER         : Lavf58.18.104
  Duration: 02:02:20.27, start: 0.000000, bitrate: 2214 kb/s
    Stream #0:0(eng): Video: vp9 (Profile 0), yuv420p(tv, bt709/unknown/unknown), 1920x1080, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 1k tbn, 1k tbc (default)
      DURATION        : 02:02:20.200000000
    Stream #0:1: Audio: aac (LC), 44100 Hz, mono, fltp (default)
      HANDLER_NAME    : SoundHandler
      DURATION        : 02:02:20.269000000
[swscaler @ 0x15eb280] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to '/home/pi/Desktop/filmekrangoruntuleri/A.R.O.G.2008.m1080p.25fps.VP9.128kbit.AAC.mkv_eg1.jpg':

To avoid any output on the command line you can redirect it into the black hole /dev/null like this:

rpi ~$ my-python3-script >/dev/null 2>&1

This will redirect error output (stderr=2) to standard output (stdout=1) (2>&1) and then redirect the standard output to /dev/null so nothing will be shown even no error messages.

You can do it also direct in your script with:

os.system('ffmpeg -ss 00:08:00 -i '+dAdi+' -frames:v 1 /home/pi/Desktop/filmekrangoruntuleri/'+egAdi+'2.jpg >/dev/null 2>&1')

If you want to suppress success messages and only see the error messages you only send the standard messages into the black hole:

rpi ~$ my-python3-script >/dev/null

And wise versa, suppressing only error messages (makes less sense):

rpi ~$ my-python3-script 2>/dev/null
  • Thank you. So how do I capture only success or error messages? – Harun Reşit Ç Dec 16 '18 at 23:48
  • Hi @HarunReşitÇ, does my answer help you? It would be nice if you could then accept it by clicking the tick on the left side. For your additional question I have updated the answer. – Ingo Dec 17 '18 at 0:57

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.