omxplayer-sync-3 icon indicating copy to clipboard operation
omxplayer-sync-3 copied to clipboard

setsynctime: Unknown method

Open jimabramson opened this issue 4 years ago • 5 comments

Hi Paul, thanks for sharing these modifications!

I have built the project (on Raspbian Jessie), and it works fine in standalone, but I'm having trouble figuring out how to make use of the sync capability.

Of the two dbus commands added in this version, setsynctime doesn't seem to be implemented in the code. When I attempt to use it, it returns Error org.freedesktop.DBus.Error.UnknownMethod: Unknown method.

Is this command supposed to be used as part of synchronizing players? If not, could you provide a tip or example of how to sync two players with this code?

jimabramson avatar Jun 28 '20 21:06 jimabramson

I'll have to review the command line switches and dbus commands and add some better documentation since I haven't looked at this in a while. But basically my modifications add a scheduler to Omxplayer that allows you to schedule and lock videos to the Raspberry Pi's system clock. In order to play synced videos across multiple Raspberry Pis, you first need a way to sync the Raspberry Pi clocks, which I think is easy to do over ethernet with NTP. Once your clocks are all in sync, if you schedule videos to play at the same time then they will play in sync. If I recall correctly, all the times for my command line switches are specified in milliseconds since 1970.

I think that dbuscontrol.sh file has not been maintained because I quit using it in my own project and started talking to dbus directly. You can see the actual dbus commands that were added if you look at OMXControl.cpp ("SetPlaylistStartTime"). But I think that if you use NTP to sync the Raspberry Pi clocks then you don't need to worry about those extra dbus commands. The time adjustment dbus command is for realtime time correction, which I don't think is necessary when using NTP to sync Raspberry Pi clocks. My own time sync system works slightly differently from NTP which is why it requires the extra dbus time adjustment command.

PaulSlocum avatar Jun 29 '20 03:06 PaulSlocum

Hey Paul, thanks for the quick reply. This information helps a lot.

In my project I'm looking to get multiple pis running a looped video in sync. I've got this somewhat working, avoiding dbus entirely (for now), by syncing the pis to ntp and then issuing identical commands across all the nodes, e.g.

omxplayer --enablesync --sloop --playliststarttime SOME_TIME_IN_THE_NEAR_FUTURE --vlength ACTUAL_VIDEO_LENGTH path_to_video.mp4

This is getting pretty close to the result I'm looking for, except that the playback sync isn't as perfect as I want it (I'm going to look into other clock sync strategies, as I want my project to be able to work without an internet connection). I'm specifying vlength because it seems to be required when playliststarttime is provided - this seems like it'll be fairly easy to work with.

Thanks again for sharing your code and advice.

jimabramson avatar Jul 01 '20 03:07 jimabramson

I wanted to add that the sync will not be perfect unless you also synchronize the HDMI video phase (or composite video phase if using composite). My code here does not do that because I needed my video phase sync program to be independent of the video player. At some point I will look into posting the video phase sync code publicly, although it's not that hard to write a phase sync program if you kinda know what you're doing. There's some information about adjusting the video clock timing on both HDMI and composite using vcgencmd hdmi_adjust_clock at the following link. You basically make the video clock run very slightly slower or faster until the frame timing aligns right with the system clock, and then set the video clock back to the normal rate and it should stay in phase for a while.

https://github.com/raspberrypi/firmware/issues/960

PaulSlocum avatar Jul 29 '20 22:07 PaulSlocum

Hi, If I use DS3231(RTC)instead of NTP and sync all pis to it will it work?( because I do not have access to internet) Would also appreciate some more documentation on installation

pramodmadhav avatar Sep 22 '20 03:09 pramodmadhav

@pramodmadhav It could potentially work, but it depends on the accuracy of the backup clocks because they will drift over time. But you don't need internet access to sync them, you can just set them up to run NTP over ethernet without the internet by connecting them all to a hub. You only need a clock battery backup if you want to avoid having wires between them.

PaulSlocum avatar Dec 14 '20 17:12 PaulSlocum