Author Topic: Play interactive videos with Raspberry from C ++.  (Read 1312 times)

0 Members and 1 Guest are viewing this topic.

Offline luiHS

  • Frequent Contributor
  • **
  • Posts: 502
  • Country: es
Play interactive videos with Raspberry from C ++.
« on: July 02, 2021, 02:19:55 am »

I have an application for Raspberry in which I need to trigger videos with sound interactively without delays, they should start playing instantly.

Now I don't use omxplayer, because I already tried it and there is a certain lag when triggering the videos, which makes it not useful for me. My current system, without using omxplayer, works fine, but does not support sound, only video.

I've looked for some info but can't find the solution, I read about using dbus to control omxplayer, but this doesn't seem to allow opening and closing video files for a background loaded omxplayer to avoid lag. It only allows you to control a video that is already in play, not open a new video or close the one that is playing.

Does anyone know any solution based or not on omxplayer, to play videos with sound from a C program? Playback must be instantaneous, there can be no lag.

If omxplayer could be controlled with dbus to send commands to open or close video files, it could help me, but it seems that that is not possible.

Offline evb149

  • Super Contributor
  • ***
  • Posts: 2222
  • Country: us
Re: Play interactive videos with Raspberry from C ++.
« Reply #1 on: July 02, 2021, 02:32:53 pm »
"videos" is rather non specific.
The file format may matter.
The video size may matter.

It may be useful to do some kinds of profiling to figure out why they don't play quickly enough when you launch a given player command.  Maybe the delay is file-system related.  Maybe the player is reading the file and indexing / validating it somehow.  Maybe it has to do with the construction of the UI and logging and whatever the program does.

Anyway possible things to look into:
ffmpeg / ffplay
videolan / vlc
vmtouch command relating to the media file
similar concept to vmtouch fadvise, madvise related system calls.
create a ramdisk backed temporary or permanent file system and play the whole file from there though that is wasteful of RAM it may not matter if it is only a few dozen/hundred megabytes in size.

it would be possible for some file formats to create a player and tell it to play the file from a "stream" e.g. network stream source.  Then create the player UI in advance, and have a streaming sender process that only starts playing out the stream over the local host network when triggered.

Simply converting your media to a different file format / encoding format may make all the difference.  Playing h.264 is very different in possible implementation from MPEG2 or MJPEG or what not.

The following users thanked this post: luiHS

Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo