kr15h / Pi-Mapper-4

Projection mapping for the Raspberry Pi 4
3 stars 0 forks source link

Test 02: Try out the video version of kmscube #2

Open kr15h opened 2 years ago

kr15h commented 2 years ago

Looking at the repository here: https://gitlab.freedesktop.org/mesa/kmscube/

kr15h commented 2 years ago

What you can see that it contains a file cube_video.c. A quick glimpse into the code reveals that it actually attempts to load a video. Further investigation into the Issues section reveals that there has been effort to make video texturing work. In the issue one can read that kmscube -V sometestvideo.mkv should work in a way. Let's try that!

I downloaded a 4K Video by Engin Akyurt from Pexels. Using ffmpeg -i Pexels\ Videos\ 1722882.mp4 I discovered that it has h264 encoding. This line in the output.

Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 3840x2160, 24147 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc (default)

But what we want is h265 as this is what Pi 4 claims to decode in hardware. ffmpeg to the rescue. Looking at the H.265/HEVC Video Encoding Guide to learn the best encoding practices. Using the following line to encode.

ffmpeg -i Pexels\ Videos\ 1722882.mp4 -c:v libx265 -crf 26 -preset fast -c:a aac -b:a 128k pexels-videos-1722882_h265.mp4

The process is slow. Getting x0.12 speed on average. So 50 seconds of video takes 10 times longer which is about 5 minutes. Done. Transfer video file to the pi.

scp pexels-videos-1722882_h265.mp4 pi@192.168.1.103:/home/pi/

Test it with omxplayer or vlc.

sudo apt install omxplayer
omxplayer pexels-videos-1722882_h265.mp4 

Error. Following output.

Vcodec id unknown: ad
have a nice day ;)

Try with VLC.

sudo apt install vlc vlc pexels-videos-1722882_h265.mp4

Seems that VLC has problems with finding decoder. Using `vlc -V fb video.mp4` via SSH gives the following. 

[b3c749e0] main decoder error: failed to create video output [b3c749e0] mmal_avcodec decoder error: Failed to update format [b38072c8] fb vout display error: cannot get terminal mode (Inappropriate ioctl for device)



It is playing back the video, but not display. Similar when trying on the Pi itself. The difference is that the screen goes black which is proof that something is going on there.
kr15h commented 2 years ago

Let's try to use the kmscube with the video. If it fails - try the original h264 video file.

kmscube -D /dev/dri/card0 -V pexels-videos-1722882_h265.mp4

Getting this.

drmModeGetResources failed: Operation not supported
failed to initialize legacy DRM

Original file time.

scp Pexels\ Videos\ 1722882.mp4 pi@192.168.1.103:/home/pi/pexels-videos-1722882_h264.mp4

Try with kmscube right away.

kmscube -D /dev/dri/card0 -V pexels-videos-1722882_h264.mp4
drmModeGetResources failed: Operation not supported
failed to initialize legacy DRM

Well. Does omxplayer and vlc play it back? No success. Leaving for later.