In my program I am writing menus direct to the framebuffer on a Raspberry Pi. This program can play videos with omxplayer and call another program to display jpeg-pictures with omxiv. If omxplayer runs before omxiv, the menus becomes invisible afterwards, and I am not able to write to the framebuffer again before I play a video with omxplayer once more. It is no help in restarting the program.
A simple example is shown here. The program draws a blue rectangle on a green background, plays a wideo and then displays an image. I had expected a blue rectangle drawn at last, but it does nt happen. Next time the program is run, the rectangle is invisible. If I play a video after omxiv, everything is OK.
Has user pi lost the permission to write to the framebuffer?
#!/usr/bin/env python
import numpy as np
from PIL import Image
import time, subprocess, os
fb = np.memmap('/dev/fb0', dtype='uint8',mode='w+', shape=(1024,1280,4))
fb[:] = [0,255,0,255]
x0, y0 = 50, 100
w, h = 300, 200
img = Image.new('RGBA', size=(w, h), color=(255,0,0,255))
n = np.array(img)
fb[y0:y0+h, x0:x0+w] = n
time.sleep(2)
os.system('omxplayer -b -r -o both video.mp4')
time.sleep(2)
subprocess.Popen('omxiv 0.jpg >/dev/null 2>&1', shell = True)
time.sleep(2)
subprocess.Popen('pkill omxiv >/dev/null 2>&1',shell = True)
time.sleep(2)
fb[y0:y0+h, x0:x0+w] = n
I solved the problem myself. Omitting the omxplayer's -b option (--blank), solves the problem:
os.system('omxplayer -r -o both video.mp4')