Peter Wiley
Peter Wiley

Reputation: 840

Why is python-vlc playback blanking screen every 5 seconds or so?

I have a python script running on a Raspberry Pi using python-vlc that plays a video when a PIR triggers it.

The video plays back, but there appears to be a black frame inserted every five seconds or so. Why is the video stuttering in this way? Is there a way to stop the stutter?

Based on reading elsewhere I thought this line

media.add_option(':avcodec-hw=none')

would help, but it does not.

Here's my full playback code:


# create vlc media player object
media_player = vlc.MediaPlayer()
media_player.set_fullscreen(True)

def playVideo(path_and_title, video_title, video_description, function):
    setLEDcolor("green")

    global PLAY_AUDIO
    global RedButton
    global BlackButton

    if PLAY_AUDIO:
        media_player.audio_set_volume(100)
    else:
        media_player.audio_set_volume(0)

    # set media object
    media = vlc.Media(path_and_title)
    media.add_option(':avcodec-hw=none')
   
    # setting media to the media player
    media_player.set_media(media)
    
    # start playing video
    media_player.play()
    mqtt.publish("player", video_title + " started.")

    # play the video to the end and then reset the break image unless
    # a button is pushed
    
    current_state = media_player.get_state()
   
    while current_state != 6:
        
        current_state = media_player.get_state()
    
        if RedButton.value == True:
            time.sleep(0.25)
            mqtt.publish("ops","The red button was pushed")
            media_player.stop()
            powerOff()

        if BlackButton.value == True:
            time.sleep(0.25)
            mqtt.publish("ops","The black button was pushed")
            if PLAY_AUDIO:
                PLAY_AUDIO = False
                media_player.audio_set_volume(0)
                mqtt.publish("player","Audio turned off")
            else:
                PLAY_AUDIO = True
                media_player.audio_set_volume(100)
                mqtt.publish("player","Audio turned on")
    

    mqtt.publish("player", video_title + " finished.")
    writeToLog("played:       " + video_title + "\n")
    # When playing the set video, we don't set the break image
    if function == "V":
        setBreakImage()

Upvotes: 0

Views: 23

Answers (0)

Related Questions