1

I'm using a Raspberry Pi 3 running Raspbian. I need to play a video file via HDMI, and I need events to be fired at specific timecodes during the playback of the video. The events are simple write operations to the GPIO. My problem is : what approach should I use to do this ?

My first approach was to use OpenCv (python) and VideoCapture(), but the raspberry pi is too slow, and my FPS is very low (I need at least 25 FPS @ 1080p).

So now I'm looking into other solutions : Gstreamer, FFMPEG, omxplayer, I read the documentations but I can't figure out which tool to use for this job.

Simon
  • 140
  • 1
  • 1
  • 12

2 Answers2

2

I finally solved this easily with omxplayer thanks to python-omxplayer-wrapper (https://github.com/willprice/python-omxplayer-wrapper)

*EDIT: this is what a basic example code would look like:

from omxplayer import OMXPlayer
from time import sleep

/* Setup the player as shown in omxplayer-wrapper examples : */
source = '../video/gray10sec.mp4'
player = OMXPlayer(source, args=['--loop', '--no-osd', '--blank'])
player.pause()
sleep(5)
player.play()

/* Make a query to position() inside infinite loop : */
while (1):
    position = player.position() * 1000
    /* Event timecodes values are stored in "events" */
    for event in events.values():
        if position - 20 <= event['tc'] and position + 20 >= event['tc']:
            /* Put your code here */

player.quit()
Simon
  • 140
  • 1
  • 1
  • 12
  • 1
    It;'s great that you solved it but apart from providing a link please include the actual solution to your problem. Stack Overflow also works like a library of solution and your contribution will help other people with the same problem in the future. – Moseleyi Oct 19 '17 at 17:01
1

You will need to write some code fro this. You could write a gpiowriter element. The element would have gobject properties for the io-pin and a controlable property for the value. Then you can attach a GstControlSource that lists timestamp:value pairs. The gpiowriter could have no pads and just run a thread and sync the properties from the controller based on the pipeline clock, or it can be a passthrough element like identity. The later would sync the properties on the frame.

ensonic
  • 3,304
  • 20
  • 31