Page 1 of 1

Possible to adjust phase of frame timing on video output?

Posted: Sat Mar 03, 2018 1:06 am
by paulslocum
I have two Raspberry Pis with their clocks synchronized to the millisecond, and I'm playing back synchronized video in Omxplayer. If I subtly shift the playback timing in Omxplayer, does that actually shift the 60Hz frame timing phase, or is the real 60Hz frame timing on some separate clock to which Omxplayer's output frames are beholden? It kinda looks like I am in fact shifting the frame timing phase by very slightly slowing down or speeding up Omxplayer, but it's hard to tell for sure what I'm seeing.

I'm primarily interested in HDMI, but I'm also curious about the composite video output's frame timing.

Re: Possible to adjust phase of frame timing on video output?

Posted: Sat Mar 03, 2018 5:09 pm
by paulslocum
Currently, my guess is that I can shift the HDMI output frame timing with Omxplayer timing adjustments as long as I don't have the "--nohdmiclocksync" flag set. When everything's working right and I'm using two identical monitors, the video synchronization does look like it's precisely on the frame. But maybe the frames are a little out of phase and I just can't see it with my current suite of test videos (which are a bit limited).

But it seems likely that the composite video output has its own 60hz clock that Omxplayer's output frames will be 'quantized' to and whose timing cannot be shifted?

Re: Possible to adjust phase of frame timing on video output?

Posted: Mon Mar 05, 2018 11:11 am
by paulslocum
I used a 120fps camera, and I can see that the video frame timing phase is not aligned even though (I think) I'm aligning Omxplayer's frame output to the millisecond. From looking at the LCD screens' refresh in slow motion, my estimate of the timing variance is +/-4 msec, although maybe I'm misreading and it's actually +/-8.3, which would make sense at a 60Hz refresh.

Re: Possible to adjust phase of frame timing on video output?

Posted: Thu Mar 08, 2018 12:51 pm
by dividuum
There is the hdmi_adjust_clock vcgencmd command that can be used to adjust the output HDMI clock frequency. There's a post somewhere in this forum that describes that using a slightly increased or decreased framerate is still within the HDMI spec. I've using this in info-beamer pi to create the "global vsync" feature that at least in theory should synchronize vsyncs across different screens.

Re: Possible to adjust phase of frame timing on video output?

Posted: Sun Mar 11, 2018 1:04 am
by paulslocum
Thanks, that's great to hear that it is possible. I haven't had time to experiment with it yet, but I'll report back when I do.

Re: Possible to adjust phase of frame timing on video output?

Posted: Sun Mar 11, 2018 10:32 pm
by paulslocum
It accepts the commands to adjust the HDMI clock frequency, but I can't figure out any way to read the pixel clock value. I see where you can read the HDMI pixel clock frequency, but how do I read the actual pixel clock position so that I can know which way to skew the HDMI clock frequency in order to match up my VSyncs?

Re: Possible to adjust phase of frame timing on video output?

Posted: Mon Mar 12, 2018 1:45 pm
by paulslocum
I see that it is possible to either get a callback or poll for VSync, so it should be possible to effectively determine the HDMI pixel clock offset that way.

Re: Possible to adjust phase of frame timing on video output?

Posted: Mon Mar 12, 2018 1:52 pm
by jamesh
paulslocum wrote:
Mon Mar 12, 2018 1:45 pm
I see that it is possible to either get a callback or poll for VSync, so it should be possible to effectively determine the HDMI pixel clock offset that way.
I'm not sure how accurate that is going to be - quite a few layers of API to get through before the callback occurs - it's jitter that more likely to be a problem i would think.

Re: Possible to adjust phase of frame timing on video output?

Posted: Mon Mar 12, 2018 2:30 pm
by paulslocum
What do you expect the jitter amount might be? Is there any possibility of exposing the pixel clock through vcgencmd?

edit: Also, I think that even if the accuracy isn't great, that you can take multiple time samples and average them to get a better idea of when VSync is really occurring relative to the system clock. I'd be reasonably happy if I could align VSyncs on multiple Raspberry Pis within a millisecond or two.

Re: Possible to adjust phase of frame timing on video output?

Posted: Wed Mar 28, 2018 4:19 am
by paulslocum
I did get frame-locked synchronized video playback working on HDMI and confirmed it with a high speed camera. The firmware currently does not allow adjustments to the composite video clock, but it might be possible -- discussion continued here:

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