1

I have created a video (with audio) player using vlc on Raspberry pi 4 board. Code and other details below. I have an HDMI screen attached on HDMI-1. I am hiding the desktop using this approach.

This code runs okay and I can see the video, however, there are two different symptoms I am facing. I don't know the problem though.

Symptom 1:

  1. The logs show below error (I have been trying to understand these logs and searching over internet for a few days - unfortunately, no luck with any of the proposed solutions). I have tried adding '--vout=mmal_vout' as suggested here, but no luck.
Apr 27 11:51:36 CAPSCREEN01 bash[605]: [974206a8] mmal_codec decoder: VCSM init succeeded: CMA Apr 27 11:51:36 CAPSCREEN01 bash[605]: [974206a8] main decoder error: buffer deadlock prevented Apr 27 11:51:37 CAPSCREEN01 bash[605]: [9730e6b0] mmal_xsplitter vout display error: Failed to open Xsplitter:opengles2 module Apr 27 11:51:47 CAPSCREEN01 bash[605]: [9741e8e8] mmal_codec decoder: VCSM init succeeded: CMA Apr 27 11:51:47 CAPSCREEN01 bash[605]: [9741e8e8] main decoder error: buffer deadlock prevented Apr 27 11:51:48 CAPSCREEN01 bash[605]: [a8c05cd0] mmal_xsplitter vout display error: Failed to open Xsplitter:opengles2 module Apr 27 11:51:58 CAPSCREEN01 bash[605]: [97421ed8] mmal_codec decoder: VCSM init succeeded: CMA Apr 27 11:51:58 CAPSCREEN01 bash[605]: [97421ed8] main decoder error: buffer deadlock prevented Apr 27 11:51:59 CAPSCREEN01 bash[605]: [a8122398] mmal_xsplitter vout display error: Failed to open Xsplitter:opengles2 module 

Symptom 2:

When the video loops, the whole screen refreshes (below two methods)

 movie_player.set_play_mode(1) movie_player.play_video(0) 

Any help to identify the problem and suggest a solution will be greatly appreciated.

My main objective here is to create a video player. I choose VLC since it has all the features that I need, i.e. playing MP4 file with Audio and Video, looping through single video, getting callback event when video finishes.

Now, I am open to change the player provided I get above features.

Video Player Code

import tkinter as tk import sys import os import vlc _isMacOS = sys.platform.startswith('darwin') _isWindows = sys.platform.startswith('win') _isLinux = sys.platform.startswith('linux') class VideoPlayer: def __init__(self, parent, videos): self.parent = parent # == root # first, top panel shows video self.video_frame = tk.Frame(self.parent) self.canvas = tk.Canvas(self.video_frame) self.canvas.pack(fill=tk.BOTH, expand=1) self.show() # VLC player args = [] if _isLinux: args.append('--no-xlib') args.append('--vout=mmal_vout') # Create vlc instance self.Instance = vlc.Instance(args) # Create Player self.player = self.Instance.media_player_new() self.player.video_set_mouse_input(True) # Create Media List Player (this is required to play video in a loop) self.playlist = self.Instance.media_list_player_new() # Set playback mode to loop # self.list_player.set_playback_mode(vlc.PlaybackMode.loop) self.set_play_mode(0) # Set Media Player to created player self.playlist.set_media_player(self.player) # Create list of media self.media_list = self.Instance.media_list_new(videos) # set media list to the player self.playlist.set_media_list(self.media_list) # set the window id where to render VLC's video output h = self.canvas.winfo_id() # .winfo_visualid()? if _isWindows: self.player.set_hwnd(h) elif _isLinux: self.player.set_xwindow(h) # fails on Windows def attached_end_video_event(self, callback): # Create an event manager object # self.player.event_manager().event_attach(vlc.EventType.MediaPlayerEndReached, callback) list_event_manager = self.playlist.event_manager() list_event_manager.event_attach(vlc.EventType.MediaListPlayerNextItemSet, callback) list_event_manager.event_attach(vlc.EventType.MediaListPlayerPlayed, callback) def stop(self, event=None): self.playlist.play_item_at_index(1) self.set_play_mode(0) def show(self): if not self.video_frame.winfo_viewable(): self.video_frame.pack(fill=tk.BOTH, expand=1) def hide(self): self.video_frame.pack_forget() def play_video(self, index): itm = self.media_list.item_at_index(index) self.player.set_media(itm) output = self.playlist.play_item(itm) def set_play_mode(self, mode): """ 0: 'default': stop after playing videos 1: 'loop' 2: 'repeat' :param mode: :return: """ # Set playback mode to loop self.playlist.set_playback_mode(mode) def startup(): videos = [ "Video1.mp4", "Video2.mp4", "Video3.mp4", "Video4.mp4" ] movie_player = VideoPlayer(root, videos) movie_player.set_play_mode(1) movie_player.play_video(0) if __name__ == '__main__': root = tk.Tk() root.geometry("640x480") root.after(1000, startup) root.mainloop() 

Board

#> cat /sys/firmware/devicetree/base/model Raspberry Pi 4 Model B Rev 1.4 

OS

 #> cat /etc/os-release PRETTY_NAME="Raspbian GNU/Linux 10 (buster)" NAME="Raspbian GNU/Linux" VERSION_ID="10" VERSION="10 (buster)" VERSION_CODENAME=buster ID=raspbian ID_LIKE=debian HOME_URL="http://www.raspbian.org/" SUPPORT_URL="http://www.raspbian.org/RaspbianForums" BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs" 

Screen

#> tvservice -s -l state 0x6 [DVI CUSTOM RGB full 4:3], 1600x1200 @ 60.00Hz, progressive 1 attached device(s), display ID's are : Display Number 2, type HDMI 0 

Troubleshooting done:

Initially I was getting below error and there was not video shown.

Apr 27 11:04:37 CAPSCREEN01 bash[1417]: [9745cbb8] mmal_codec filter error: Failed to enable output port vc.ril.hvs:out:0(BGRA) (status=1 ENOMEM) Apr 27 11:04:37 CAPSCREEN01 bash[1417]: mmal: mmal_vc_port_enable: failed to enable port vc.ril.hvs:out:0(BGRA): ENOMEM Apr 27 11:04:37 CAPSCREEN01 bash[1417]: mmal: mmal_port_enable: failed to enable port vc.ril.hvs:out:0(BGRA)(0x974014f0) (ENOMEM) 

After reading reading somewhere (I find that link now. I increased the GPU Memory to 256). It started showing me the video after this update.

VLC Plugins

#> ls -l /usr/lib/arm-linux-gnueabihf/vlc/plugins/mmal/ total 960 -rw-r--r-- 1 root root 140796 Jan 18 2021 libmmal_avcodec_plugin.so -rw-r--r-- 1 root root 272032 Jan 18 2021 libmmal_codec_plugin.so -rw-r--r-- 1 root root 136596 Jan 18 2021 libmmal_converter_plugin.so -rw-r--r-- 1 root root 140744 Jan 18 2021 libmmal_deinterlace_plugin.so -rw-r--r-- 1 root root 140748 Jan 18 2021 libmmal_vout_plugin.so -rw-r--r-- 1 root root 136596 Jan 18 2021 libmmal_xsplitter_plugin.so #> ls -l /usr/lib/arm-linux-gnueabihf/vlc/plugins/video_output/ total 368 -rw-r--r-- 1 root root 9620 Jan 18 2021 libaa_plugin.so -rw-r--r-- 1 root root 13768 Jan 18 2021 libcaca_plugin.so -rw-r--r-- 1 root root 9620 Jan 18 2021 libegl_wl_plugin.so -rw-r--r-- 1 root root 9620 Jan 18 2021 libegl_x11_plugin.so -rw-r--r-- 1 root root 13708 Jan 18 2021 libfb_plugin.so -rw-r--r-- 1 root root 9620 Jan 18 2021 libflaschen_plugin.so -rw-r--r-- 1 root root 58836 Jan 18 2021 libgles2_plugin.so -rw-r--r-- 1 root root 67028 Jan 18 2021 libgl_plugin.so -rw-r--r-- 1 root root 9620 Jan 18 2021 libglx_plugin.so -rw-r--r-- 1 root root 9664 Jan 18 2021 libvdummy_plugin.so -rw-r--r-- 1 root root 9612 Jan 18 2021 libvmem_plugin.so -rw-r--r-- 1 root root 13772 Jan 18 2021 libwl_shell_plugin.so -rw-r--r-- 1 root root 13796 Jan 18 2021 libwl_shm_plugin.so -rw-r--r-- 1 root root 21908 Jan 18 2021 libxcb_window_plugin.so -rw-r--r-- 1 root root 13724 Jan 18 2021 libxcb_x11_plugin.so -rw-r--r-- 1 root root 21920 Jan 18 2021 libxcb_xv_plugin.so -rw-r--r-- 1 root root 13880 Jan 18 2021 libxdg_shell_plugin.so -rw-r--r-- 1 root root 9612 Jan 18 2021 libyuv_plugin.so #> ls -l /usr/lib/arm-linux-gnueabihf/vlc/plugins/video_splitter/ total 64 -rw-r--r-- 1 root root 9680 Jan 18 2021 libclone_plugin.so -rw-r--r-- 1 root root 34256 Jan 18 2021 libpanoramix_plugin.so -rw-r--r-- 1 root root 13776 Jan 18 2021 libwall_plugin.so 

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.