Video Playback Customization
Please see Customisable Video Playback.
Modifying Refresh Rates to suit your Video Playback
Traditionally, the refresh rate of your TV was set to either 50hz (PAL) or 60hz (TV) and any mismatch between that frequence and frame rate of your encoded Video was accomodated by:
1. A process called Telecine (more info is at http://en.wikipedia.org/wiki/Telecine on the Telecine patterns used to do this). If the Telecine Pattern used is not an exact multiple you will experience "Telecine Judder" as a side effect.
2. Simply changing the playback speed (more info is at http://en.wikipedia.org/wiki/PAL_speedup#576i_speed-up). A side effect of the 4% PAL speedup (running a Film at 25fps over the original 24fp) is that pitch is slightly higher on Audio and the film is 4% shorter.
A second issue occurs due to the slightly different speeds in which our equipment plays back the Video and Audio tracks and the method used to by the PC to keep the twoin sync by either occasionally inserting or droping Video frames.
Video playback is smoothest when the refresh rate of your monitor/TV matches (or is an exact multiple of) the frame rate of the media you are watching. Typically you will want to watch:
- PAL Based Material @ 50hz
- NTSC Based Material @ 60 or 24hz
- Film/Blu-ray/HD-DVD Material @ 24hz
Thankfully our modern PC and TV/Monitors are not fixed at one refresh rate so we can dynamically change this to suit the material we are playing back. For MC users there are two different solutions available to enhance smooth video playback in this situation:
1. Change Display Settings in MC: MC allows you to define what resolution & refresh rate you want your Video files to be played back at. To do so you simply play the video file then "Right Click --> Change Display Settings --> select the appropriate resolution/refresh rate". This value is then stored in the MC library in the "Playback Info" field and MC will automatically change your TV/Display to the stored resolution/refresh rate for that file then back to your default when finished.
2. Using ReClock to change your Display Settings: Reclock is a free Direct Show Audio filter (http://forum.slysoft.com/forumdisplay.php?f=85) specifically designed to address a number of problems from poor timing mismatch when playing video on PCs. When commencing playback ReClock will determine what frame rate the Video file is encoded in and can optionally run a VBS that can then change your PCs refresh rate to suit. An example of such a file is posted in this thread http://yabb.jriver.com/interact/index.php?topic=50146.0 . Additionally, ReClock also changes how the clocks are used to modify the Audio track playback instead of the Video track to keep the two in sync and prevent adding or dropping Video Frames. More on the background to Reclock is below
Extract from the Reclock Read Me
The following is the part of the 22page Readme that comes with the Reclock install that describes the issue, background, and solution taken to get smooth video playback.
What is ReClock?
Said simply the purpose of ReClock is to definitely get rid (I hope) of jerky playback of AVI and MPEG material on a PC (or a PC connected to a TV).
ReClock is born from my own frustration. I have a fast PC, a good video card, and when I play a DVD or DIVX on my brand new Home Cinema, I get dropped frames here and there for no reason, or a completely jerky and un-watch able movie. This is very annoying.
The following sections will give you a complete and I hope clear explanation of what cause jerky playback, and how ReClock will try to solve these problems.
The last section will give you the instructions on how to install and use ReClock.
The not so great history of frame rates
In basic terms, a video can be thought of as being made up of numerous snapshots, called frames. The frame rate is the number of frames displayed each second
As you know there exist 3 common broadcasting formats: cinema, TV, and computers
Cinema is the oldest. It is the format of the movies you see in your favourite theater. Cinema movies play at 24 frames per second ( fps). It’s very simple: every 1/24th of a second, your see a new frame. This is also called “progressive scan”. A television, however, does not deal with video in terms of frames. Instead, it displays video using half-frames, called fields. Each frame contains exactly two fields. One field is made up of the odd horizontal lines in a frame. This is called the odd field or the top field since it contains the top line of the image. The other field is made up of the even horizontal lines in a frame. This is called the even field or bottom field. This way to broadcast video is called “interlaced scan” Now there are three common TV standards: PAL, SECAM and NTSC. All of them use “interlaced scan”. Let’s start with PAL, which is the European TV standard. It is also used for DVD and DIVX material. PAL material is played at 25 fps (or 50 fields per second). You see the first problem here: how can we play a 24 fps movie on a 50 fields per second PAL TV? Well first of all, we can present each movie frame two consecutive times to make the movie play at 48 fields per second. But playing the movie like this would give jerky playback every second because one movie picture would be missing. So the movie is just played 50/48 times faster to match 50 fields per second. So a cinema movie that has duration of 60mn plays on PAL in 57mn36 seconds. That’s why movies you watch on your PAL TV are always a bit shorter in time.
SECAM is the French brother of PAL and works exactly the same way. It is still used in France because it gives better colours when broadcasted by radio waves (less sensitive to noise).
And now here is NTSC, the American brother of PAL. NTSC is also used for DVD and DIVX material, and plays somewhere near 29.97 fps (to be exact it is 4.5 MHz/286/525). You see a bigger problem here. How can we play cinema movies on NTSC. Accelerate them? Sure no, because you would notice that the film plays much too fast (a 60mn movie would play in 48mn3s). So NTSC engineers came with a solution called “telecine” or “3:2 pulldown” which is quite complicated. To convert a film that runs at 24 fps to run at 29.97 fps, it is first necessary to slow down the video by 0.1% to 23.976 fps. Then approximately 6 frames are added to the video each second, bringing the frame rate to 29.97 fps. This is done by adding one extra frame to each group of 4 film frames. Although they could simply duplicate 1 out of every 4 frames to produce the extra frame, this method is not used. This is because the duplication of one frame would cause that frame to be displayed for twice as long as the other 3 frames, which leads to jerkier motion. Fortunately, film producers can make use of the field-based nature of video to more gradually introduce the extra frame. Instead of adding a whole new frame at once, 2 fields are introduced separately to each group of 4 film frames. Since 2 fields make up a frame, this method is equivalent to adding 1 new frame. However, since the 2 duplicated fields are not added at the same time, this reduces the jerkiness of the video.
Let’s finish with computers. Computers are quite simple, they just do work like cinema and use “progressive scan”. But they use many more frame rates: 60 Hz, 75 Hz, 85 Hz, 100 Hz when watching your monitor, 50 Hz when connected to a PAL TV, and 60 Hz when connected to a NTSC TV. To obtain a smooth playback on a PC you just have to make sure that your video card uses a refresh rate that is an exact multiple of the movie you play. You can already see that PAL can be played fine at 50 Hz, 75 Hz or 100 Hz, but NTSC cannot be played without begin jerky because all we have is 60 fps which is not a multiple of 29.97 fps.
The nightmare of badly born DIVX
DIVX for the most are created from DVD material, and DVD material generally comes from movie material.
DIVX created from PAL material are generally fine, because they were created from 24 fps material simply accelerated to 25 fps or from direct 25 fps material. PAL is a good guy.
And now you have telecine for NTSC. Since telecine can only be displayed correctly on “interlaced scan” hardware, it must be removed for PC playback. This operation is called “inverse telecine”. Doing this on a film will revert the frame rate of the movie to 23.976 fps. Funny, but … jerky on every PC you will use to play the movie.
Some people that create DIVX from NTSC don’t even know that inverse telecine must be done. So those DIVX stays at 29.97 fps and will have artefacts when watched on your PC because interlacing artefacts do not compress well at all.
And to add another thing to the story, some DIVX has sound and movie sync problems that are solved by … modifying the frame rate a little bit so the movie duration matches the sound track duration. This is a quick and dirty way to do it. Imagine a 25 fps DIVX that is modified to play at 25.001 fps; well every 1000 frames (that’s only 40 seconds) the playback will become jerky.
The bigger nightmare of PC hardware
When you connect your PAL DVD player to your TV, things are really simple. Your player read the movie from the disc at 25 fps, and sends the signal to the TV at 25 fps. Now imagine that your player is a little too fast and send the movie to the TV at 25.01 fps. What will happen? Jerkiness? No … In fact your TV is smart, and will stay synchronised with your player as long at the player plays near 25 fps. To be more precise no player in the world plays the movie exactly at 25 fps because clocks are never accurate. So every player play the movie “near” 25 fps, but this is no problem for your TV since it is locked to the video signal it receive.
Now when you play a DIVX on your PC and watch it on your PC what happens? First of all, if the refresh rate of your monitor is not a multiple of the frame rate of your DIVX, jerkiness will happen for sure. Do you remember that DIVX can be 24 fps, 25 fps, 23.976 fps, 29.97 fps, or even 25.001 fps? This is the first and main cause of jerky playback.
The other source of jerkiness is much more subtle and harder to understand. Suppose you play a 25 fps movie on you PC. Well your PC isn’t smarter that any DVD player, it will play it “near” 25 fps because it uses its internal clock, which is inaccurate. But it should not be a problem because DVD players also do that? Bad luck, it is a very big problem, because your video card does not synchronise its speed with the speed of the movie like a TV would do with a DVD player. In a PC the clocks used in the video card (to show the video) and in the PC (to play the video) are completely distinct, thus there always is deviation between them, and then jerkiness is inevitable.
The better history of DirectShow
DirectShow is the DirectX component that plays or record video and audio on your PC. DirectShow contains many modules called “filters” and connect them in a “filter graph” to finally render the movie. Let’s take an example, with the steps needed to play a DIVX movie: - First you need to demux the audio and video from the AVI file: one filter will do that and will produce two streams (audio + video) - Then you need to decode audio stream (MP3 for example): a MP3 decoder filter will do that - You also need to decode video: a DIVX decoder filter will do that - You must render the decoded movie in a window: a video renderer filter is needed - You must play decoded audio: an audio renderer is used.
DirectShow was cleverly designed because it will automatically search and find what filters are the best to render a movie. For example, the audio and video renderers are completely generic (they are provided by Microsoft) and will eat the output of every decoder filter in the world. That’s one reason why there exist many DIVX players out there. A player is only a nutshell where filter graphs are built and run.
Now, DirectShow has another interesting feature. When building a filter graph, it set up a “reference clock” that is used to provide a unique time to all the filters in the graph. All filters will play their stuff at the speed of the reference clock. The default reference clock in DirectShow is provided by the Microsoft sound renderer. Why? Because in order to play sound correctly, your sound card must receive samples exactly at the speed they will be played. So the default reference clock is in fact synced to a hardware clock somewhere in your sound card. Video frames just follow this clock, making jerkiness inevitable.
You may ask why Microsoft made this choice. They could have chosen to sync the reference clock to the video and all would be nice. I suppose they didn’t for at least two reasons: - Video cards do not have a high-resolution hardware timer available to make a clock. - Sound playback would become problematic since the sound card would not receive its samples at the speed they would be played. So the sound would not stay synchronised with video
Here comes ReClock
Now I think you understand what does ReClock. It provides a reference clock that is synchronised with your video hardware. How? By replacing entirely the default sound renderer with a new rewritten DirectShow filter that is somehow cleverer.
But by doing so, ReClock must solve the two problems we saw in the last section: - Video cards do not have a high-resolution hardware timer available to make a clock: well, this is not completely true, since many of them have something that will help us. ReClock provides a reference clock based on a high-resolution timer based on hardware on your motherboard or your processor. Let’s call this clock the “system clock”. Then, ReClock will correct the system clock with information gathered in real time from your video card if they are available. How it does that will be my little secret :) - Sound playback would become problematic: this is true. How can we solve that? By varying the speed of the sound in real time to force the sound to stay in sync with the video. This is another reason why we replace the sound renderer with our own one. There are two ways to change sound speed: playback speed and pitch. Normally, ReClock will choose to change the pitch of the sound in real time by adjusting the audio clock because it’s quite easy to do and does not degrade too much sound quality. It also allows very fine tuning on the video vs. sound synchronisation. This will however change a little bit the sound you will hear, but your ears should not notice that with such a low correction. Starting with version 1.4, you can also ask ReClock to combine audio pitch change with audio time stretching witch allow to change the playback speed without noticeable pitch artefacts.
Another thing that does ReClock is to change the global playback rate of the movie in order to match its frame rate to a multiple of the refresh rate of your monitor. Here is how it does that: - CINEMA mode is detected if the monitor has a refresh rate that is a multiple of 24 Hz (72 Hz, etc…) and if the movie has a frame rate between 23.75 and 24.25. Then the playback rate of the movie (including sound) is modified to match exactly 24 fps. - PAL mode is detected if CINEMA mode wasn’t possible and if the monitor has a refresh rate that is a multiple of 25 Hz (50 Hz, 75 Hz, 100 Hz, etc…) and if the movie has a frame rate between 23.75 and 25.25. Then the playback rate of the movie (including sound) is modified to match exactly 25 fps. - NTSC mode is detected if the monitor has a refresh rate that is a multiple of 30 Hz (60 Hz, 120 Hz, etc…). Then the playback rate of the movie (including sound) is modified to match exactly 30 fps. - CUSTOM mode is detected when the frame rate of the movie +/- 2% is a multiple of the monitor refresh rate. Then the playback rate of the movie (including sound) is modified to match exactly a multiple of the monitor refresh rate. Finally if nothing matched, ReClock will try to match the playback rate is not modified, but the reference clock is still synchronised to the video card in order to obtain a stable clock.
Side note: you may ask if NTSC will work well with TV since PC does 30 fps where the TV wants 29.97 fps. That’s a good question to which I do not have a complete response, but strangely I observed that when I use ReClock with the excellent TvTool in NTSC mode with a GeForce 3, I get a clock correction that make the reference clock work near … 29.97 fps. So it seems that when the PC uses TV out in NTSC mode, the refresh rate is not 60 Hz, but 29.97*2 Hz, but I’m not sure at all of that, since it may be a coincidence. Anyway playing NTSC at 30 fps on a NTSC TV should not be a problem; as you may know NTSC was originally a black/white standard at 30 Hz that became 29.97 Hz for technical reasons when colour appeared.
So by adjusting the reference clock to match your video card, adjusting the sound to stay in sync with picture, and modifying the global playback rate, ReClock should allow a smooth movie experience on your monitor and even on your TV.
But as I said before, ReClock will not work with all PC because it uses some functions that are not available on all of them. Firstly your PC must support high-resolution timers (nearly every modern PC has them). Secondly, your video card must support some special calls. I know that most nVidia, ATI, Intel i815 and Matrox G200 do support those calls, but some cheaper or older cards may not. If those functions are not supported, ReClock will not load at all or will display an error message and the Microsoft audio renderer will be used.
Moreover, ReClock has some constraints you need to understand: - ReClock requires DirectX 9.0 or later. - ReClock will load and work only if your movie has sound, because ReClock is an audio renderer. - ReClock will not always find the frame rate of the material. For example streaming will never be supported. - When your run ReClock for the first time for a specific resolution and refresh rate, the reference clock will be inaccurate during the first minutes of playback while being corrected. This can cause jerky playback at the beginning of the movie. The time to obtain an accurate clock will depend on many factors (initial error of clock, PC speed …). During this period, you will see a flashing yellow/red icon in the system tray. After this adjustment the icon will become green (or yellow), and ReClock will store the correction in the registry, so when you will open another media, the clock correction parameters will be retrieved. - Changing the playback speed can be noticeable on sound especially when 23.976 fps material is up rated to 25 fps. Doing so will accelerate the sound by 4%, and sound will seem to be a little high pitched. If you don’t like that, you can enable the “audio time stretching” function (explained later in this document).