Post subject: Smooth video playback
creaothceann
He/Him
Editor
Joined: 4/7/2005
Posts: 1874
Location: Germany
One thing that the encoding package is concerned with is avoiding video/audio desyncs, i.e. resampling the audio to fit the video's length and framerate. Some (all?) TV-based consoles don't run at exactly a framerate of 60 or 50 Hz though. (The official, interlaced, NTSC standard defines the framerate to be 60/1.001 Hz, but analog TVs are flexible enough to allow some variation.) Flatscreen PC monitors usually support 60.0 Hz, some also support frequencies such as 60.0/1.001 Hz either officially or via custom frequency settings. So to ensure absolutely smooth video playback on most PC monitors, the framerate should be set to 60 Hz and the audio's sample rate changed to fit the new video length. This is what I did for the Secret of Evermore temporary encode:
Language: Avisynth

AVISource("00a.avi", "00b.avi", "00c.avi", "00d.avi") # 256×224 AddBorders(0, 8, 0, 8) # 256×224 → 256×240 PointResize(Width * 3, Height * 3) # 256×240 → 768×720 (TV aspect ratio: Youtube tag "yt:stretch=4:3") AssumeSampleRate(round(60.0 * FrameRateDenominator / FrameRateNumerator * AudioRate))#.ResampleAudio(AudioRate) AssumeFPS(60) Trim(0, -313200) # 1:27:00.0
Site Admin, Skilled player (1237)
Joined: 4/17/2010
Posts: 11275
Location: RU
I had this idea long ago, but such a sharp turn needs higher approval which I doubt it will get.
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
creaothceann
He/Him
Editor
Joined: 4/7/2005
Posts: 1874
Location: Germany
feos wrote:
such a sharp turn
Is it, though? It's just a few additional lines... Anyway, the SNES framerate (progressive mode) is 2684659/44671 fps, i.e. ~60.0985 fps. Changing that to 60.0 fps would add ~5.91 seconds to every hour of video, which is not really noticeable for the viewer. What is noticeable though is the unavoidable consistent extra frame every ~10.3 seconds without this change, which is especially noticeable in scrolling sections.
Lex
Joined: 6/25/2007
Posts: 732
Location: Vancouver, British Columbia, Canada
Actually, it's not true that PC monitors advertised to run at 60Hz do run at that. The RetroArch people tested a bunch of monitors, including my Acer G24 from 2007, and they are mostly 59.94-59.95Hz. RetroArch synchronizes with the detected refresh rate and uses dynamic audio sample rate to synchronize. Your code is good, but should AssumeFPS(59.95) instead of 60. Edit: What really should be done is fixing the playback rate in the video player. I'm sure nevcairiel/madshi could do it in LAV Filters/madVR if they wanted to.
creaothceann
He/Him
Editor
Joined: 4/7/2005
Posts: 1874
Location: Germany
Lex wrote:
Actually, it's not true that PC monitors advertised to run at 60Hz do run at that. The RetroArch people tested a bunch of monitors, including my Acer G24 from 2007, and they are mostly 59.94-59.95Hz.
That's not been my experience though... Got a link to relevant thread(s)?
Lex wrote:
What really should be done is fixing the playback rate in the video player.
Possible with ReClock, not possible for Youtube videos.
Lex
Joined: 6/25/2007
Posts: 732
Location: Vancouver, British Columbia, Canada
creaothceann wrote:
Lex wrote:
Actually, it's not true that PC monitors advertised to run at 60Hz do run at that. The RetroArch people tested a bunch of monitors, including my Acer G24 from 2007, and they are mostly 59.94-59.95Hz.
That's not been my experience though... Got a link to relevant thread(s)?
The relevant discussion was on IRC in the #ssnes channel on freenode in 2012 or 2013. RetroArch has an estimated monitor refresh rate measurement tool in its video settings, which usually comes to ~59.95Hz after its maximum sample frame count of 2048 and stays there. You can try it yourself. Many display drivers and displays report incorrect refresh rates. Android device displays are notoriously bad for this, advertising 60 Hz and only running at some random rate between 58 and 59 Hz. This caused the RetroArch devs to add a feature that manually tested the monitor refresh rate to find the optimal rate.
creaothceann wrote:
Lex wrote:
What really should be done is fixing the playback rate in the video player.
Possible with ReClock, not possible for Youtube videos.
It is possible for YouTube, but Google has to implement it, unfortunately, and we know how difficult that sort of thing is. It would be much easier to get nevcairiel or madshi, who are so familiar with the DirectShow video playback chain, to do something like ReClock. I tried ReClock for this exact purpose a while back, but it seemed buggy as all hell at that time. Does it work better now?
creaothceann
He/Him
Editor
Joined: 4/7/2005
Posts: 1874
Location: Germany
Alright, I tested RetroArch 1.2.2 on 4 monitors; every time the monitor's frame rate set to 60.0Hz, Aero not disabled: PC 1: - NVidia Geforce 970 - OS: Windows 7 64-bit - RetroArch: 64-bit - monitor 1: Acer GN246HL - monitor 2: Hanns.G JC198D PC 2 "Wintron 10.1 SurfTab": - integrated graphics - OS: Windows 8.1 32-bit - RetroArch: 32-bit - Estimated Monitor Framerate PC 3: - NVidia Geforce 460 - OS: Windows 7 64-bit - RetroArch: 64-bit - monitor: BenQ G2222HDL I might be able to test an XP laptop later. --------------------------------------------------------------------------------
Lex wrote:
I tried ReClock for this exact purpose a while back, but it seemed buggy as all hell at that time. Does it work better now?
Well - it works fine enough for me. On PC 1 I used it for many months with the BenQ, which was set to 50 Hz, to watch anime and movies which were sped up by ReClock from 24.0/1.001 to 25 Hz, without any problems. Now the Acer, which is a 144 Hz display, is connected to that PC and set to 120.0/1.001 Hz so that I can watch both ~23.976 and ~59.94 Hz videos; ReClock is only used rarely. Only on the SurfTab I had some cases where MPC-HC crashed when starting a video; it always worked on the second try though. It probably depends on the settings that you use.
Lex
Joined: 6/25/2007
Posts: 732
Location: Vancouver, British Columbia, Canada
creaothceann wrote:
Alright, I tested RetroArch 1.2.2 on 4 monitors; every time the monitor's frame rate set to 60.0Hz, Aero not disabled: PC 1: - NVidia Geforce 970 - OS: Windows 7 64-bit - RetroArch: 64-bit - monitor 1: Acer GN246HL - monitor 2: Hanns.G JC198D PC 2 "Wintron 10.1 SurfTab": - integrated graphics - OS: Windows 8.1 32-bit - RetroArch: 32-bit - Estimated Monitor Framerate PC 3: - NVidia Geforce 460 - OS: Windows 7 64-bit - RetroArch: 64-bit - monitor: BenQ G2222HDL I might be able to test an XP laptop later.
Nice results. Mine always ends up blinking between 59.952 and 59.956 Hz, and the author had the same results back when he implemented it. I'm using Windows 7 with an Nvidia GTX 690 and the OpenGL driver in RetroArch and an Acer G24 monitor from 2007. What graphics driver did you have set in RetroArch? ("gl" is their code for "OpenGL")
creaothceann
He/Him
Editor
Joined: 4/7/2005
Posts: 1874
Location: Germany
The default one, i.e. "gl".
Joined: 10/14/2013
Posts: 335
Location: Australia
What about video renderers like madvr? Is it better to adjust the encode ever so slightly when monitors themselves vary or is it better to leave it true to whatever the console's refresh rate is and rely on the user's system to make the adjustments? I'm out of my knowledge zone here, but I do know that madvr makes 40fps footage seem smooth on a ~60fps AOC monitor.
I'm not as active as I once was, but I can be reached here if I should be needed.
creaothceann
He/Him
Editor
Joined: 4/7/2005
Posts: 1874
Location: Germany
thecoreyburton wrote:
What about video renderers like madvr? Is it better to adjust the encode ever so slightly when monitors themselves vary or is it better to leave it true to whatever the console's refresh rate is and rely on the user's system to make the adjustments?
I can't speak for other consoles, but the SNES's framerate in progressive mode is faster than 60 Hz, so changing it to 60 would benefit in the cases where the monitor runs at <= 60 Hz, even without further correction (e.g. in case of YT videos). If the user has something like ReClock then the video and audio quality wouldn't be affected unless the audio is configured to be resampled (instead of just its sample rate value being adjusted), but this resampling generally shouldn't produce any audible differences.
thecoreyburton wrote:
I do know that madvr makes 40fps footage seem smooth on a ~60fps AOC monitor.
madvr has a "smooth motion" setting, but I've never used it. It might adjust the video/audio playback rates or create blended frames.
Lex
Joined: 6/25/2007
Posts: 732
Location: Vancouver, British Columbia, Canada
A 60 fps video would still be slightly too fast for my monitor, which apparently runs at ~59.95 Hz despite the driver being set to and incorrectly reporting 60 Hz. That may not be the case for all the monitors you tested, but I assure you that there are others like mine that are pretty common. It's probably most common in North America, I'd guess. Maybe Germans are smarter about their displays. :) Does YouTube max out at 60 Hz?
creaothceann
He/Him
Editor
Joined: 4/7/2005
Posts: 1874
Location: Germany
Lex wrote:
A 60 fps video would still be slightly too fast for my monitor, which apparently runs at ~59.95 Hz despite the driver being set to and incorrectly reporting 60 Hz.
Well, at least the stutter would be less pronounced at 60 fps than at ~60.0985 fps. Maybe you can create a custom resolution?
Lex wrote:
Does YouTube max out at 60 Hz?
Afaik yes.
Lex
Joined: 6/25/2007
Posts: 732
Location: Vancouver, British Columbia, Canada
creaothceann wrote:
Lex wrote:
A 60 fps video would still be slightly too fast for my monitor, which apparently runs at ~59.95 Hz despite the driver being set to and incorrectly reporting 60 Hz.
Well, at least the stutter would be less pronounced at 60 fps than at ~60.0985 fps. Maybe you can create a custom resolution?
Nah, I've done a lot of testing in the past including trying custom resolutions, multiple machines, and different video cards in this one, and it's the monitor's limitation.
Lex
Joined: 6/25/2007
Posts: 732
Location: Vancouver, British Columbia, Canada
creaothceann wrote:
Lex wrote:
Does YouTube max out at 60 Hz?
Afaik yes.
If so, you should definitely set the rate to 60 if it's over 60 anyway. Otherwise, YouTube itself is going to simply drop frames in its transcode.