@@lgp_yt I ended up using 1 big video and seeking through it, as i did not need the result to be perfectly seamless. The biggest problem for me was getting hardware acceleration working for some reason, the video was extremely laggy and did not work with audio. (The solution was to update to 64-bit Rpi OS, enable cma-384, and enabling glamour acceleration).
thank you so much for sharing your (exausted) journey to save our skin ! The format is very cool too find the perfect solution for a project. And as a french, still happy to heard "Vé Elle Cé Meh dia pléyeur" :p
I had a lot of trouble with the performance of python-vlc (libvlc), and I need sound, so the solutions presented in this video are not applicable. What did work is controlling an HTML video via Javascript. Works smoothly in fullscreen, and there's plenty of guides for how to loop it. I recommend this avenue if you need sound.
Hi Le Grille-Pain, Thank you for your very interesting video ! I'm currently working on a project requiring a perfect loop with a raspberry pi 4. I've done quite a few tests with Gstreamer, the result is better than with VLC, but there's still a micro-freeze and it doesn't accept 4K videos. So I tested your solution with openCV and thanks for your good work! However, I have a question: do you know how I could avoid storing the video in RAM? Because I only have 2GB in the raspberry pi, and I need more for a lot of my videos...
Hello ! Thank you for your comment, happy to hear that my video is still useful! VLC4.0 and the Raspberry Pi 5 have now been released, have you tried any of them ? I have no idea about the decoding capabilities of the Pi5 and haven't tested VLC4.0 yet, but they might be your answer. Concerning openCV, the better solution to avoid filling the RAM would be to create a (circular?) buffer (what I'm discussing around 17:10) and have a decoding thread that decode and copy frames in the buffer while another thread is displaying them. A bit more complex than my dirty solution 🙃
Hi, thanks for this, very very informative. I am trying to sync some LED animations running at 60fps with the video playing in the background and ran into issues with VLC player having indeterministic delays in starting/pausing/playing the video causing it to be out of sync with the start of the LED animation. This experiment was run on an RPi 3B+ with decent performance (the LED animation per 16.66ms frame took about 3ms even with the video running in the background). I was wondering about the performance of your method? Does playing back the video frame by frame cause any frame delays vs using libVLC in python? I plan to try your method by starting a separate python thread to run the LED animations @ 60fps in parallel with the video playing @ 24fps. Any issues you think I might encounter if I run this on a 3B+ instead of a 4 as well?
Hi, Thank you for your comment, glad that the video was helpful! As I said in the video, the video was actually playing too fast at first when playing directly the decoded frames from RAM, so performance was not an issue. I cannot comment about the deterministic side of the code, but copying data to a framebuffer should still be fast enough that any time variation shouldn't cause a problem.
@@lgp_yt Thanks! I ended up implementing a 50 length queue framebuffer which I was filling in another python thread as I could barely fit a few seconds of video in the limited RAM in the 3B+ however the decoding time per frame was slightly above the frame timing needed to hit a consistent 30fps meaning that the buffer eventually exhausted after some time of the video playing. I'm going to try to see how my ffmpeg is configured as I'm guessing I'm not leveraging the hardware decoding when I call read() as the CPU usage is spiking to 100% on one core when I start decoding. I think this approach will work for me though once I find out the best way to decode using HW acceleration.
@@st-zw7yw I'm not very familiar with HW video decoding on the Pi3 (so I might be wrong) but if I remember correctly, the PI3 was able to use omxplayer with a h264 video to play a video directly, have you looked into this option ? Maybe try using a .h264 file as it was done on the famous "hello_video" example ? Also, take a look at this topic on the Pi forums, it was a very helpful resource while I was working on this project : forums.raspberrypi.com/viewtopic.php?t=317511
Great video. This looks like exactly the solution I'm looking for; however, I can't seem to install python-vlc on my Pi 4. I get the following error: error: externally-managed-environment × This environment is externally managed ╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install. I have tried every variation of the install command I can think of in terminal and have had no luck. Do you have any suggestions? Thanks! .
Glad that you liked the video! I'm indeed not following the Python best practice by not using a virtual env for my packages. Have you tried simply "apt install python3-vlc" ?
A year later, I find myself in a similar situation, although I want to sync two videos perfectly. This explanation comes in pretty handy, but my terminal shows me in the end following error: fcntl.ioctl(fb_fd, FBIO_WAITFORVSYNC) OSError: [Errno 16] Device or resource busy anyone encountered this as well?
Hi there, I haven't used this project for a while now, but it seems that some updates on the Pi4 breaks some stuff. A quick checklist: Are you using the right video drivers ? Does running your code as root solve the issue ? Are you running this from a desktop environment ?
The code provided in the GitHub isn't a fully working program but several examples to illustrate what I've tried in the video, it needs some tweaks to add your sensors and/or your video paths (look at the main() function) Once that's done the script itself doesn't take any command line parameters, you only have to launch it using python3
Thank you for your comment! I added some installation instruction on GitHub, don't hesitate to tell me if something isn't working : github.com/iadjedj/lgp_rpi_video
Amazing. very clear and coherent with all my questions answered. Thank you sir.
I am doing a project which is very similar, thanks for talking through your whole process. Saved me a bunch of time learning what didn't work and why.
I'm glad that my video was helpful!
What did you end up using on your project?
@@lgp_yt I ended up using 1 big video and seeking through it, as i did not need the result to be perfectly seamless. The biggest problem for me was getting hardware acceleration working for some reason, the video was extremely laggy and did not work with audio. (The solution was to update to 64-bit Rpi OS, enable cma-384, and enabling glamour acceleration).
thank you so much for sharing your (exausted) journey to save our skin ! The format is very cool too find the perfect solution for a project.
And as a french, still happy to heard "Vé Elle Cé Meh dia pléyeur" :p
Thank you for all the investigation and testing
I had a lot of trouble with the performance of python-vlc (libvlc), and I need sound, so the solutions presented in this video are not applicable. What did work is controlling an HTML video via Javascript. Works smoothly in fullscreen, and there's plenty of guides for how to loop it. I recommend this avenue if you need sound.
Love it: informative, smart and funny! (J'adore une petite tartine et 3:27)
Super informative, thank you very much for your work !
Thank you for this video. Very informative and enjoyable!! Subscribed
good complete explanation, it's helpful to me
Hi Le Grille-Pain,
Thank you for your very interesting video !
I'm currently working on a project requiring a perfect loop with a raspberry pi 4.
I've done quite a few tests with Gstreamer, the result is better than with VLC, but there's still a micro-freeze and it doesn't accept 4K videos.
So I tested your solution with openCV and thanks for your good work!
However, I have a question: do you know how I could avoid storing the video in RAM? Because I only have 2GB in the raspberry pi, and I need more for a lot of my videos...
Hello !
Thank you for your comment, happy to hear that my video is still useful!
VLC4.0 and the Raspberry Pi 5 have now been released, have you tried any of them ? I have no idea about the decoding capabilities of the Pi5 and haven't tested VLC4.0 yet, but they might be your answer.
Concerning openCV, the better solution to avoid filling the RAM would be to create a (circular?) buffer (what I'm discussing around 17:10) and have a decoding thread that decode and copy frames in the buffer while another thread is displaying them. A bit more complex than my dirty solution 🙃
Merci ! Is it possible to create a video file with last 20 seconds after a command? The idea is to create replay videos.
this is very close to what I need for a project. Are you able to help me program something for a Raspberry Pi?
Hi,
Have you seen the GitHub link : github.com/iadjedj/lgp_rpi_video ?
What are you struggling with ?
Hi, thanks for this, very very informative.
I am trying to sync some LED animations running at 60fps with the video playing in the background and ran into issues with VLC player having indeterministic delays in starting/pausing/playing the video causing it to be out of sync with the start of the LED animation. This experiment was run on an RPi 3B+ with decent performance (the LED animation per 16.66ms frame took about 3ms even with the video running in the background).
I was wondering about the performance of your method? Does playing back the video frame by frame cause any frame delays vs using libVLC in python? I plan to try your method by starting a separate python thread to run the LED animations @ 60fps in parallel with the video playing @ 24fps. Any issues you think I might encounter if I run this on a 3B+ instead of a 4 as well?
Hi,
Thank you for your comment, glad that the video was helpful!
As I said in the video, the video was actually playing too fast at first when playing directly the decoded frames from RAM, so performance was not an issue.
I cannot comment about the deterministic side of the code, but copying data to a framebuffer should still be fast enough that any time variation shouldn't cause a problem.
@@lgp_yt Thanks! I ended up implementing a 50 length queue framebuffer which I was filling in another python thread as I could barely fit a few seconds of video in the limited RAM in the 3B+ however the decoding time per frame was slightly above the frame timing needed to hit a consistent 30fps meaning that the buffer eventually exhausted after some time of the video playing.
I'm going to try to see how my ffmpeg is configured as I'm guessing I'm not leveraging the hardware decoding when I call read() as the CPU usage is spiking to 100% on one core when I start decoding. I think this approach will work for me though once I find out the best way to decode using HW acceleration.
@@st-zw7yw I'm not very familiar with HW video decoding on the Pi3 (so I might be wrong) but if I remember correctly, the PI3 was able to use omxplayer with a h264 video to play a video directly, have you looked into this option ? Maybe try using a .h264 file as it was done on the famous "hello_video" example ?
Also, take a look at this topic on the Pi forums, it was a very helpful resource while I was working on this project : forums.raspberrypi.com/viewtopic.php?t=317511
Great video. This looks like exactly the solution I'm looking for; however, I can't seem to install python-vlc on my Pi 4. I get the following error:
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
I have tried every variation of the install command I can think of in terminal and have had no luck.
Do you have any suggestions? Thanks!
.
Glad that you liked the video!
I'm indeed not following the Python best practice by not using a virtual env for my packages.
Have you tried simply "apt install python3-vlc" ?
@@lgp_yt That worked, thanks! Now I just need to familiarize myself with the player api!
MASTERCLASS !
A year later, I find myself in a similar situation, although I want to sync two videos perfectly. This explanation comes in pretty handy, but my terminal shows me in the end following error:
fcntl.ioctl(fb_fd, FBIO_WAITFORVSYNC)
OSError: [Errno 16] Device or resource busy
anyone encountered this as well?
Hi there,
I haven't used this project for a while now, but it seems that some updates on the Pi4 breaks some stuff.
A quick checklist: Are you using the right video drivers ? Does running your code as root solve the issue ? Are you running this from a desktop environment ?
once your code in installed what are the commands to play a video?
The code provided in the GitHub isn't a fully working program but several examples to illustrate what I've tried in the video, it needs some tweaks to add your sensors and/or your video paths (look at the main() function)
Once that's done the script itself doesn't take any command line parameters, you only have to launch it using python3
Great video. Could you maybe give a list of stuff I have to install to make your code work?
Thank you for your comment!
I added some installation instruction on GitHub, don't hesitate to tell me if something isn't working : github.com/iadjedj/lgp_rpi_video
Tu es français