• 1
  • 18
  • 19
  • 20(current)
  • 21
  • 22
  • 26
Jittery Video?
As a personal experiment, I've tried to solve this and I've come a long way, but because I'm not an expert on the xbmc code I can't implement it properly (yet).

The problem:

Videocards and soundcards have their own clock, which is always slightly different from the system clock, so if the display's refreshrate is set at 60 hertz, compared to the system clock it might be 60.01 hertz or 59.99 hertz.
Video output in xbmc is synchronized to the system clock (which is periodically synced by the audio clock as far as I can tell) and it tries to reproduce the source framerate as good as it can.

This means that, if you have a 60 hertz display and play a 29.97 fps movie, some frames will be shown longer or shorter than needed, to keep the video in sync with the audio, this is what causes the jerky playback.

The solution:

Xbmc should determine how many times a frame should be shown, and show it exactly that many times. If the display is 60 hertz and a 29.97 fps movie is being played, the optimal situation is that every frame is showed exactly twice, causing the movie to be played at 30 fps.
If a 23.976 fps movie is played, every first frame should be shown two times and every second frame should be shown three times, causing the movie to be played at 24 fps.

The audio thread should check how far off sync it is, and resample the audio so it will play faster/slower to keep the audio in sync with the video.

What I have done:

The video thread determines how many times a frame should be shown, it then does the required number of calls to g_renderManager.FlipPage (thanks to elupus for the tip).
After that, the clock is updated to the pts of the frame.

The audio thread doesn't sync the clock anymore, instead it resamples the audio (using libsamplerate) to stay in sync, using a simple proportional algorithm with an offset correction (measure the average error for one second, if it's more than 10 ms out of sync, correct it and let it stabilize for three seconds).

There are some problems with it, fast-forwarding doesn't really work and on some xvid movies the clock seems to stop when black frames are showed.
Also, if decoding a frame takes longer than the time between two vsync interrupts, the movie slows down and things start to sound like a broken record player.

Overall I'm quite happy with it, and I'm sure these issues can be solved.
Reply
WOW!

Fantastic work.
Do you think you could share that version with us?
I woul love to try it. Jitter free playback on XBMC has been a dream for me, but I simply don't have the skill to implement it like you did.
Reply
bobo1on1 Wrote:As a personal experiment, I've tried to solve this and I've come a long way, but because I'm not an expert on the xbmc code I can't implement it properly (yet).

The problem:

Videocards and soundcards have their own clock, which is always slightly different from the system clock, so if the display's refreshrate is set at 60 hertz, compared to the system clock it might be 60.01 hertz or 59.99 hertz.
Video output in xbmc is synchronized to the system clock (which is periodically synced by the audio clock as far as I can tell) and it tries to reproduce the source framerate as good as it can.

This means that, if you have a 60 hertz display and play a 29.97 fps movie, some frames will be shown longer or shorter than needed, to keep the video in sync with the audio, this is what causes the jerky playback.

The solution:

Xbmc should determine how many times a frame should be shown, and show it exactly that many times. If the display is 60 hertz and a 29.97 fps movie is being played, the optimal situation is that every frame is showed exactly twice, causing the movie to be played at 30 fps.
If a 23.976 fps movie is played, every first frame should be shown two times and every second frame should be shown three times, causing the movie to be played at 24 fps.

The audio thread should check how far off sync it is, and resample the audio so it will play faster/slower to keep the audio in sync with the video.

What I have done:

The video thread determines how many times a frame should be shown, it then does the required number of calls to g_renderManager.FlipPage (thanks to elupus for the tip).
After that, the clock is updated to the pts of the frame.

The audio thread doesn't sync the clock anymore, instead it resamples the audio (using libsamplerate) to stay in sync, using a simple proportional algorithm with an offset correction (measure the average error for one second, if it's more than 10 ms out of sync, correct it and let it stabilize for three seconds).

There are some problems with it, fast-forwarding doesn't really work and on some xvid movies the clock seems to stop when black frames are showed.
Also, if decoding a frame takes longer than the time between two vsync interrupts, the movie slows down and things start to sound like a broken record player.

Overall I'm quite happy with it, and I'm sure these issues can be solved.

I would like to the patches for this for investigation under osx.
Reply
Here it is: http://www.xs4all.nl/~loosen/xbmc-reclock.rar

You also have to link to libsamplerate, I added -lsamplerate to the LIBS variable in the makefile.
At the moment, targetfps is hardcoded at 60 fps in DVDPLayerVideo.cpp.
Reply
bobo1on1 Wrote:Here it is: http://www.xs4all.nl/~loosen/xbmc-reclock.rar

You also have to link to libsamplerate, I added -lsamplerate to the LIBS variable in the makefile.
At the moment, targetfps is hardcoded at 60 fps in DVDPLayerVideo.cpp.

libsamplerate (also known as Secret Rabbit Code), hehe. Thanks, got it.
Reply
bobo1on1 Wrote:Here it is: http://www.xs4all.nl/~loosen/xbmc-reclock.rar

You also have to link to libsamplerate, I added -lsamplerate to the LIBS variable in the makefile.
At the moment, targetfps is hardcoded at 60 fps in DVDPLayerVideo.cpp.
BWAHAHAHAHAHWAHAHAHAH (mad laughter of joy). Big Grin Big Grin Big Grin

The RAR's title is filling my heart with sunshine. I knew this day would come. Praise ye gods! Big Grin

Thanks bobo1on1! I will follow this with eager anticipation.
Reply
Shouldn't bobo1on1 work be moved to the development forums? I would say that here it risks being overlooked by other developers that might be interested.
Reply
You don't need to be afraid I'm looking at it Wink
Once finalized he can open a ticket and it can go it's way. Development questions can be opened in the Development forum ofc.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
Thanks WiSo, much appreciated.
Reply
Great news Smile

Please see http://trac.xbmc.org/ticket/59 which is the original issue (it also describes how to do something similiar with passthrough audio)

Best Regards,
Olli
Reply
mpw222 Wrote:I managed to fix this problem by disabling vsync in xbmc, but forcing it on through the nvidia control panel. I went from +/- .4fps to +/-.02fps.

Before finding this thread i did the exact same thing except i have ati mobility radeon x600 with mobility catalyst 9.1 as driver on windows xp.

I tried to find why video was stuttering even when there are no dropped frames.
Found that by disabling vsync from xbmc and settings "Wait for vertical refresh to Quality (Always On)" in Ati control panels 3D settings fixed the problem.

So this works for ati too.
Reply
Great news with the reclock thing Smile
Reply
i use "adjustrefreshrate" option in my advancedsettings.xml for resolve video stuttering and smooth play.
Code:
<videoplayer>
    <adjustrefreshrate>true</adjustrefreshrate>
</videoplayer>
Reply
queeup Wrote:i use "adjustrefreshrate" option in my advancedsettings.xml for resolve video stuttering and smooth play.
Code:
<videoplayer>
    <adjustrefreshrate>true</adjustrefreshrate>
</videoplayer>

There is no <adjustrefreshrate> in the advancedsettings.xml.
Reply
http://wiki.xbmc.org/?title=Advancedsett...I_settings

look here.
Reply
  • 1
  • 18
  • 19
  • 20(current)
  • 21
  • 22
  • 26

Logout Mark Read Team Forum Stats Members Help
Jittery Video?1