0

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
Eddy Sorngard
  • 149
  • 1
  • 12
  • I don't understand. You say your program is unable to write to the framebuffer after `omxiv` is run, yet your program doesn't even try to write to the framebuffer after `omxiv`, it does so **before** `omxiv` runs? – Mark Setchell Nov 21 '19 at 19:35
  • The first time I run the program after a reboot, I can see the rectangle followed by the jpg-image. If I start the program once more, the recyangle is not visible, but only the jpg-image. I have to reboot before starting the program to see the rectangle again. – Eddy Sorngard Nov 24 '19 at 12:47
  • Try using a stronger signal than SIGTERM, maybe SIGKILL (9). Try running `lsof` to see if `omxiv` is still holding the framebuffer device open. – Mark Setchell Nov 24 '19 at 17:37
  • pkill -9 omxiv does not help, and lsof does not list anything about omxiv or fb0. – Eddy Sorngard Nov 24 '19 at 20:54

1 Answers1

0

I solved the problem myself. Omitting the omxplayer's -b option (--blank), solves the problem:

os.system('omxplayer -r -o both video.mp4')
Eddy Sorngard
  • 149
  • 1
  • 12