Tweak PC clocks

One of the problems I have with my ongoing TV-PC project is that the display frame rate doesn't always match the rate at which frames arrive from the broadcaster. At times I've seen it having to drop 1 full frame (i.e. two interlaced) every four seconds or so, which is an error of 1%.

I originally put this down to inaccuracies in the display card, but when measured against the system's clock, it appears exact. Presumably it's synchronized to it (as it should be!).

Which suggests that it's the system clock that's inaccurate. What I'm really looking for is the ability to tweak the system clock frequency while the system is running. Google has not been my friend. Anyone heard of the use of such a technique with normal PC products?

Sylvia.

Reply to
Sylvia Else
Loading thread data ...

Your system clock supports spread spectrum, but good luck biasing it by 1% over the long run.

I highly doubt the system clock is your problem. There are numerous crystals inside a computer. The video card usually has several of its own.

Why not simply run a higher refresh rate? I was getting 60Hz vibration of my screen here (ambient fields), so I cranked it up from

75 to 85Hz. Problem solved.

But then, I happen to have a Trinitron that supports 1600 x 1200 at

85Hz. ;-)

Tim

Reply to
Tim Williams

On a sunny day (Wed, 14 Oct 2009 12:49:17 +1100) it happened Sylvia Else wrote in :

On a PC, the vertical frequency is generted by the graphics card. There is no relation between that and the incoming video stream (say from some TV station). So, indeed frames are dropped on a regular basis. The solution is called 'genlock', where the graphics card oscillator is locked to the incoming video. This is difficult, only the most expensive Nvidia cards have a genlock input IIRC, Then there is the minor issue of digital audio... One could (as I do with a small PAL cmera) use some varicap to tune the graphics card xtal oscillator, and somehow do a phase compare between the monitor V sync and the incoming Vsync... An interesting project :-)

Reply to
Jan Panteltje

Or duplicated, which is worse - particular with interlaced frames, unless special treatement is given to such frames when they're duplicated.

to

IIRC,

graphics

It doesn't really need to be phase locked. Merely adjusting the frequency up and down at intervals would be sufficient, provided the tweaks are sufficiently small (and it should be possible to make them small) that the image size isn't affected in a noticeable way.

BTW, it appears from further more precise measurements that I was wrong about the video card being synched to the system clock. Indeed, the frame rate drifts a bit.

Which begs the question of how it's supposed to issue sync interrupts properly. Then again, my card (a Matrox G450) seems unable to do that - interrupts get lost frequently.

Sylvia.

Reply to
Sylvia Else

Sylvia Else Inscribed thus:

Some BIOS allow for an interrupt to be assigned to the video card.

--
Best Regards:
                Baron.
Reply to
baron

On a sunny day (Thu, 15 Oct 2009 11:19:01 +1100) it happened Sylvia Else wrote in :

You need gen lock:-)

It is a rather complicated subject. In case of TV, and assuming you are in the US and I think the NTSC frame rate was 29.9700 Hz, and your monitor sync 60 Hz...

The video is stored in a buffer in the PC, usually 2 levels deep (one is written to while the other one is read out), and the graphics card reads from one of those buffers at the time.. at it's own rate (60 x per second). Here is a link for Nvidia cards, that explains some of those issues:

formatting link

I dunno about Matrox, never used those, I use Linux an Nvidia.

There is a lot more to just 'display', if you go one level up in that link:

formatting link
plenty of info, although manufacturer specific, the concept is the same.

One 'way around' your issue is to record the digital (I presume) video from the TV station to disk, and then play that file, in that case you can do a buffer flip in sync with the video, It is time shift, but needs not be much shifted (say a few seconds in a 90 minute movie). I almost always watch time shifted, as it allows me to stop when commercials occur, keep the recorded movie if I like it, and just gives a lot of freedom.

All this will not work if your source is 25 fps and your monitor can only do 60 fps, as most LCDs for PC use... then you end up with irregular jumps if things are moving.

I never claimed digital video was in any way better then the old analog system as far as motion is concerned. It is all compromise, lossy system, most people do not care, especially if they forked out so much self justification will make it look better :-) OTHO the recordings are much better then VHS tape ever was, unlimited copying without quality loss... and normally the occasion fame drop does not really bother me when watching a movie, it only shows up badly on some material.

But I look from a Linux POV, write much of the soft myself, so this may not help MS windows sufferers a lot.

I did read an article in a German magazine some days ago, that stated that something like 25% of the people had moments they wanted to throw their PC out of the window, because they got so frustrated with it. I once kicked a disk drive so hard it stopped working, I kicked because it had continuous problems. That fixed (killed) it, I bought a new one this time a Seagate, end of problems.

So, keep cool, if you lose your cool, hehe LOL

Reply to
Jan Panteltje

No, I'm in Australia, with 25Hz frames and 50Hz refresh - nominally.

written

I'm working lower down - writing directly to the frame buffer in synch with the display. It works fine except for the slight frame rate mismatch which forces me to drop frames or duplicate them. I'd like to avoid doing either.

It has a particularly good composite video out. With the Nvidia card composite video out, I could never get rid of extraneous noise. It appears that Nvidia didn't really care about it - just included it as a selling point.

Sylvia.

Reply to
Sylvia Else

On a sunny day (Thu, 15 Oct 2009 22:52:56 +1100) it happened Sylvia Else wrote in :

Then where did you get a 50Hz capable monitor? Or are you using a CRT? All PC LCDs I can buy here (in Europe also 25 fps) are 60 Hz,

written

Yes, then you have a mismatch. The only way I can think of to fix that, is to record first, and then play back while syncing to the card's V refresh. That causes then an audio issue?

Yes, true, I had to make some VHS copies from a production I made, so I tried to record that from the Nvidia composite out, but the colors were incorrect. Very strange, I looked up the chip, to see if I could do something with registers. But then simply made a SVCD, and played that via the DVD player to the VHS. Problem solved.... better quality.

Reply to
Jan Panteltje

written

You'll need to resample the image to match the output frame rate so the dropped/duplicated frame is smeared into the other frames.

--
Failure does not prove something is impossible, failure simply
indicates you are not using the right tools...
                     "If it doesn\'t fit, use a bigger hammer!"
--------------------------------------------------------------
Reply to
Nico Coesel

e
g
-

s written

ne

tml

I run into similar issues in the US where there will be a little bit of audio stutter. The PC uses ATI graphics and an ATI HDTV wonder. To get it to behave, I just pause it for a second or two and then let it play. The Hauppauge tuner does something like it but that machine is mainly a recorder. The recodings play fine with no video or audio quirks.

G=B2

Reply to
Glenn Gundlach

It's driving a CRT TV.

You're right that LCDs tend not to support 50Hz, but there are certainly some that do that are available in the UK. For example

formatting link

written

back while syncing to the card's V refresh.

That tends to be a slight issue anway. I just delete or add sound samples, with a bias towards doing it at quiet moments. Seems to work.

Sylvia.

Reply to
Sylvia Else

On a sunny day (Fri, 16 Oct 2009 10:42:52 +1100) it happened Sylvia Else wrote in :

Ah, yes, after posting that I realised you were having TV connected to your composite out.

Interesting. That allows for a line doubler card. I still have one of those, it makes 50 Hz 15625 Hz into 50 Hz 31250 Hz, by repeating every horizontal scan line twice at double the speed (uses only one line memory). I have an old Philips TV1500 PCI TV card that does that. It works fine with my old CRT monitor, but my LCD does not want the 50 Hz. A relay switches the VGA input of the monitor between that card and the graphics card... Always full screen... I did the same in an FPGA using the internal RAM as line store. But now there are no more analog transmissions here, all is digital, both terrestrial and from satellite.

There are digital LCD TV receivers in the shops here that do 50 Hz.. Problem solved if you are a TV watcher.. For editing video material on the PC the whole frame issue is not important.

So, conclusion: Get a nice digital TV that does 50 Hz, 1920 x 1080 full HD or so...

I watch TV on the PC with the xine program in Linux. Best program for TV watching, allows aspect and zoom change with some keys on the keyboard while running. And I almost always use time-shifting.

Here my recording program xdipo, just released a new version:

formatting link

Here the script I use to watch live, it calls xdipo, also my ceefax / teletext decoder jpvtx, and decoder jpinfo:

formatting link
Can watch the ceefax / videotext with my program xvt-p :-) All under hot keys on the keyboard.

To watch terrestrial TV on the PC, I did it this way: ftp://panteltje.com/pub/dvb-t-nl.txt

mmm, I have fixed some audio video sync problems that way in existing material in the long ago past, by deleting between sentences in the audio... took a long time... Hope any of this in of is of use to anybody :-) xdipo has hundreds of downloads...

Does Australia still have digital TV already? Or is it still analog PAL mostly?

Reply to
Jan Panteltje

They're currently running in parallel, with a few new digital only channels added as a sweetner (but it's mainly more of the same rubbish, of course). Analogue switch off allegedly starts sometime next year in metropolitan areas.

Sylvia.

Reply to
Sylvia Else

What frequency were you expecting ? NTSC TV is actually broadcast at

29.97 fps not exactly 30. That's 0.1% out already.

Broadcasters have 'house sync' to which every device is locked to avoid the kind of problem you're having. It'll happen with digital audio too. Effectively you need to sync your PC video card to the incoming video signal with a PLL presumably.

Graham

Reply to
Eeyore

Surprisingly, no, 'cos I'm not in an NTSC area.

When it comes down to it, a PLL is just a way of adjusting the frequency of an oscillator to maintain a phase relationship. I was pondering the scope for doing the same at a programming level.

What comes out of a digital tuner card is not reguarly spaced single frames anyway, so there's nothing to lock to at that level. Any frequency adjustment would have to be based on longer term average frame rates. The same would be true for sound.

Sylvia.

Reply to
Sylvia Else

On a sunny day (Tue, 20 Oct 2009 10:14:34 +1100) it happened Sylvia Else wrote in :

If you are talking 'digital transport stream', and in that mpeg2 (for example), then each frame has a 'presentation timestamp'. The presentation timestamp tells the software when (= at what moment in time) to display the frame. Audio frames also have a presentation timestamp, as do subtitles. IIRC the whole digital system is based on a 27 MHz master clock.

I have played many years ago by changing that presentation timestamp in recorded digital video to get control over the audio-video sync. It worked very well:-) But the guys at linuxtv.org did not like it. You easily can get out of decoder (or buffer) range that way I think.

It may be worth to really dig a bit deeper in the theory of the digital transmission format. There ETSI docs

formatting link
IIRC) are the reference, there are a great many of those related to DTV, and there are some very good publications about it on the internet. It is by no means simple.

Reply to
Jan Panteltje

to display the frame.

Yes, they have presentation time stamps. But that merely tells you when they should be displayed/played relative to each other. Indeed, the timestamps on frames are absolutely predictable - each is the standard frame time ahead of the previous. It is not possible, even in principle, to derive the broadcaster's clock from them.

Sylvia.

Reply to
Sylvia Else

On a sunny day (Wed, 21 Oct 2009 00:17:25 +1100) it happened Sylvia Else wrote in :

example),

to display the frame.

But I do not want the broadcasters clock. I was thinking about spacing x frames in y positions evenly. Of course that may require an ever growing buffer (FIFO), or dropping frames if the broadcast is faster, but then you have more control over when to drop one. Just an idea... :-)

You also could display slightly slower on purpose, and simply always use a fifo, simply mkfifo my_fifo will create a nice fifo file in Linux.

But time shifting solves everything, plus it has many more advantages.

Reply to
Jan Panteltje

example),

time) to display the frame.

fifo, simply

I'm pretty sure that a Linux FIFO file has limited buffer space, and will block the input side if the output side isn't read fast enough.

I wonder what digital TVs and set top boxes do.

Sylvia.

Reply to
Sylvia Else

On a sunny day (Wed, 21 Oct 2009 10:33:59 +1100) it happened Sylvia Else wrote in :

fifo, simply

Nope, as all in Linux, the only limit is disk space. When moving from MS DOS to Linux in the last century the 'limit' on everything disappeared magically :-) It started with my text editor (I used Boxer on MS win 3.1 (that ran on top of MS DOS, or DR DOS actually), replaced by 'joe' in Linux. 'Joe' will happily edit a 10 GB or bigger file.

In settop boxes the display can be synced to the incoming stream. In fact settop boxes often run some variant of Linux. Example:

formatting link
Same for digital TVs.

The high end Philips ones now also run Linux :-)

Reply to
Jan Panteltje

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.