paulslocum
Posts: 70
Joined: Sun Apr 09, 2017 10:54 pm

Possible to adjust phase of frame timing on video output?

Sat Mar 03, 2018 1:06 am

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.

paulslocum
Posts: 70
Joined: Sun Apr 09, 2017 10:54 pm

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

Sat Mar 03, 2018 5:09 pm

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?

paulslocum
Posts: 70
Joined: Sun Apr 09, 2017 10:54 pm

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

Mon Mar 05, 2018 11:11 am

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.

User avatar
dividuum
Posts: 108
Joined: Sun Jun 16, 2013 1:18 pm
Location: Germany
Contact: Website

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

Thu Mar 08, 2018 12:51 pm

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.
info-beamer hosted - A user and programmer friendly digital signage platform for the Pi: https://info-beamer.com/hosted

paulslocum
Posts: 70
Joined: Sun Apr 09, 2017 10:54 pm

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

Sun Mar 11, 2018 1:04 am

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.

paulslocum
Posts: 70
Joined: Sun Apr 09, 2017 10:54 pm

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

Sun Mar 11, 2018 10:32 pm

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?

paulslocum
Posts: 70
Joined: Sun Apr 09, 2017 10:54 pm

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

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.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 20065
Joined: Sat Jul 30, 2011 7:41 pm

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

Mon Mar 12, 2018 1:52 pm

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.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

paulslocum
Posts: 70
Joined: Sun Apr 09, 2017 10:54 pm

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

Mon Mar 12, 2018 2:30 pm

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.

paulslocum
Posts: 70
Joined: Sun Apr 09, 2017 10:54 pm

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

Wed Mar 28, 2018 4:19 am

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

Return to “Graphics programming”

Who is online

Users browsing this forum: No registered users and 3 guests