Closed hijak closed 1 year ago
It's tricky to find any good examples of displaying to an LED matrix like ours - so perhaps we need one - but here's some discussion suggesting that python-gstreamer and python-gobject are likely candidates for playing a video stream to Unicorn HAT HD: https://stackoverflow.com/questions/7227162/way-to-play-video-files-in-tkinter
There's also this GStreamer tutorial, but it makes my head spin! - https://brettviren.github.io/pygst-tutorial-org/pygst-tutorial.html
i paid a guy off fiver to figure it out :) mainly cause i was on the verge of crying hahah
#!/usr/bin/python3
import cv2
import subprocess as sp
import numpy
try:
import unicornhathd as unicorn
print("unicorn hat hd detected")
except ImportError:
from unicorn_hat_sim import unicornhathd as unicorn
VIDEO_URL = "tcp://picamera.exnet.lan:5000"
FFMPEG_BIN = "ffmpeg"
unicorn.rotation(270)
unicorn.brightness(0.6)
pipe = sp.Popen([ FFMPEG_BIN, "-i", VIDEO_URL,
"-loglevel", "quiet", # no text output
"-an", # disable audio
"-f", "image2pipe",
"-pix_fmt", "bgr24",
"-vcodec", "rawvideo", "-"],
stdin = sp.PIPE, stdout = sp.PIPE)
while True:
raw_image = pipe.stdout.read(640*480*3) # read 432*240*3 bytes (= 1 frame)
image = numpy.fromstring(raw_image, dtype='uint8').reshape((480,640,3))
image1 = cv2.resize(image,(16,16))
for x in range(16):
for y in range(16):
[r,g,b] = image1[x,y]
unicorn.set_pixel(x, y, r, g, b)
unicorn.show()
if cv2.waitKey(5) == 27:
break
cv2.destroyAllWindows()
i was pretty close which was a kicker
i love the camera example and have tried to adapt it for streaming m3u8 but my novice python skills are no match. any one have a good example of displaying any video on the unicorn hat hd?