1

(Xubuntu 18.04, Python 3.6.9)

I am working on a little application for myself with very simple usage of the vlc module. It's a console-based application using curses, and vlc is interjecting its output in the middle of my terminal interface. I can't figure out how to silence it. Have read libvlc docs, nothing about it that I can find. Have tried the advice from this similar question, no success after setting sys.stderr = open('stderr.txt', 'w+'). Have not been able to locate anything in the libvlc docs or running vlc -H. I don't really care if I'm able to access the output; I just need it to not print in the console.

Here is all my VLC-related code, probably unnecessary in this case:

def vlc_init():
    global vlc_instance, media_player
    vlc_instance = vlc.Instance('--no-xlib') # VLC asked me to pass '--no-xlib' *shrug*
    media_player = vlc_instance.media_player_new()

def set_new_media(media_path):
    media = vlc_instance.media_new(media_path)
    media_player.set_media(media)

Does anyone know what I can do?

1 Answer 1

2

From vlc -H:

Console logger (console)
 -q, --quiet, --no-quiet        Be quiet
                      (default disabled)
   Turn off all messages on the console.

So yea, just call your vlc instance with one of those flags enabled, and redirect stderr to /dev/null for good measure.
vlc_instance = vlc.Instance('--no-xlib -q > /dev/null 2>&1')

Sign up to request clarification or add additional context in comments.

2 Comments

Perfect solution, thanks so much! Am I correct in thinking that this is a Linux-specific solution, at least the > /dev/null 2>&1 part? Like these are bash commands that are getting run?
oh yea yea, it is. Didn't even think about it 'cuz VLC's been just about standard-issue in Linux distros for years. believe it would be fine on Mac's, 'cuz they have a similar OS. Win's the odd one out -- stackoverflow.com/questions/4507312/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.