marijnkampf / Random-Photo-Screensaver

Source of Random Photo Screensaver
http://www.abscreensavers.com/random-photo-screensaver/open-source
Other
45 stars 14 forks source link

Video playback very slow (choppy) #30

Open FlixFlix opened 9 years ago

FlixFlix commented 9 years ago

System: Windows 8, three monitors, high performance i7 CPU.

Video playback is very choppy (probably less than ~10 fps), regardless of format or resolution.

marijnkampf commented 9 years ago

What is your video playback like in Internet Explorer? To test, when you're watching a video press F12 to save the current screen(s) to html files, open these in IE. Also what version of IE is installed on your system?

FlixFlix commented 9 years ago

I just realized that the performance issues are not limited to video playback. Any kind of transition (zoom&pan, slide, fade, etc.) is very choppy.

IE version: 11.0.9600 CPU: i7-4770k @ 4Ghz 3 monitors: 2@1920x1200, 1@1680x1050

Opened the three HTML files generated by F12 in three IE windows and the animations are BUTTERY SMOOTH, with CPU usage around 5%.

During screensaver though, CPU usage goes up to almost 50% (it's probably 100% as far as the screensaver is concerned since it's a multi-core CPU).

I also tried disconnecting two monitors and run the screensaver in single monitor mode but it's still choppy.

Choppy demo (3 monitors): https://www.dropbox.com/s/rwtfass9hwlf847/Video%20Apr%2029%2C%2011%2021%2045-1.m4v?dl=0

Choppy demo (1 monitor): https://www.dropbox.com/s/0b8w64aweqh5vvo/Video%20Apr%2029%2C%2011%2024%2046-1.m4v?dl=0

Smooth demo in IE: https://www.dropbox.com/s/yr6f19lz4pzt10u/Video%20Apr%2029%2C%2011%2028%2031-1.m4v?dl=0

marijnkampf commented 9 years ago

Could you try adding the following registry key and see whether it makes a difference?

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_GPU_RENDERING] "RPS4.exe"=dword:00000001

See https://msdn.microsoft.com/en-us/library/ee330731(v=vs.85).aspx#gpu_rendering for additional information on the above registry setting.

If it improves performance on your system too (my CPU usage dropped from ~34% to ~15% when playing a video) I'll add it to the installer.

FlixFlix commented 9 years ago

I added this GPU key to both local machine and current user, but no noticeable improvement (I did not track CPU usage, just a visual check). I also tried setting FEATURE_BROWSER_EMULATION to IE11 as documented in this MSDN page.

Further observations As stated before, the photo transitions are buttery-smooth when viewed in Internet Explorer. However, video playback is still choppy, even in IE. See the example below (left monitor IE window, right monitor VLC media player). Notice how smooth the cars are moving in VLC on the right and how bad it is on the left: https://www.dropbox.com/s/7hponm2bq2spo0j/video.m4v?dl=0

marijnkampf commented 9 years ago

Are you using the latest RPS version? FEATURE_BROWSER_EMULATION won't make a difference as this is set with <meta http-equiv="X-UA-Compatible" content="IE=edge"/> in monitor.html.

It could be an issue with video playback in IE. You could try using VLC ActiveX plugin http://www.ehow.com/how_8750586_install-plugin-vlc.html and see whether that does the trick. Please note I haven't tested this. From RPS version 4.4.1 you can use VLC ActiveX instead of Windows Media Player for playback.

Create a file _monitor.js in %programdata%\Random Photo Screensaver\data\js\ (or %localappdata%\Random Photo Screensaver\data\js\ see where there are already files) and use the two functions below as a base to alter the component used.

function getVideoObject(source, settings) {
    var playCount = 1;
    var stretch = "";
    if (settings.stretchSmallVideos) stretch = " stretch";
    if (settings.loop) playCount = 9999;
    html = '<object class="object media' + stretch + '" id="mediaPlayer" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"'
            + 'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"'
            + 'standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">'
            + '<param name="FileName" value="' + source + '" />'
            + '<param name="Mute" value="' + settings.mute + '"/>'
            + '<param name="playCount" value="' + playCount + '"/>'
            + '<param name="AutoStart" value="True" />'
            + '<param name="AutoSize" value="True" />'
            + '<param name="DefaultFrame" value="mainFrame" />'
            + '<param name="ShowStatusBar" value="0" />'
            + '<param name="AllowScan" value="true" />'
            + '<param name="CanSeek" value="true" />'
            + '<param name="windowlessVideo" value="true" />'
            + '<param name="ShowPositionControls" value="' + settings.showcontrols + '" />'
            + '<param name="SendPlayStateChangeEvents" value="true">'
            + '<param name="showcontrols" value="' + settings.showcontrols + '" />'
            + '<param name="ShowAudioControls" value="' + settings.showcontrols + '" />'
            + '<param name="ShowTracker" value="0" />'
            + '<param name="EnablePositionControls" value="0" />'
            + '<embed type="application/x-mplayer2"'
            + 'name="mediaplayer"'
            + 'pluginspage="http://www.microsoft.com/Windows/MediaPlayer"'
            + 'src="' + source + '"'
            + '</embed>'
            + '</object>';
    window.settings = settings;
    window.mediaPlayerFileName = source;
    window.timeOut = 1;

    oldPlayer = document.getElementById('mediaPlayer');
    if (oldPlayer != null) {
        try {
            oldPlayer.PlayState = 0;
            oldPlayer.pause();
        } catch(e) {
        }
    }
    $("#mediaPlayer").remove();
    return html;
}

function getVideoObjectOnLoaded() {
    if (document.getElementById('mediaPlayer') != null) {
        duration = document.getElementById('mediaPlayer').Duration;
        var interval = window.settings["play.interval"] / 1000;
        var start = getStartPosition(duration, interval, window.settings);
        if (start != false) document.getElementById('mediaPlayer').currentPosition = start;
    }
}

There is a small change you might need to manually update the above code to stay in line with future releases of RPS.

FlixFlix commented 9 years ago

Honestly, I'm not quite sure what to do with the above stuff; the only thing I could think of was replacing the http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab (which doesn't even exist... 404) with an axvlc.cab I found online and uploaded to my server. Anyway, no effect whatsoever, I even removed the "+codebase [...]" line completely; the videos are still being played by the microsoft media player as evidenced by the blue controls at the bottom.

Second issue still remains - photo transitions, while tolerable, are not nearly as smooth as when they're played inside IE. CPU usage for RPS4.exe is over 15%, while three separate IE windows playing the photos take less than 1%. Is there any info I could provide to diagnose the problem?

marijnkampf commented 9 years ago

Could you try the latest version (4.5.7) from http://www.abscreensavers.com/random-photo-screensaver/ ?

FlixFlix commented 9 years ago

Tried the latest version on my PC (Windows 8); no difference whatsoever.

New findings I fired up a Windows 7 VMware box with IE11 and the results are as follows:

As an added bonus, some videos have the wrong orientation (upside-down).

marijnkampf commented 9 years ago

Could you try disabling video smoothing in WMP settings? Are you playing the videos from local stored file or network?

marijnkampf commented 9 years ago

For those who come across this bug, please try http://www.abscreensavers.com/abdownloads/rps/setup-rps4.5.7.1.exe (probably won't make a difference, but your feedback is appreciated)

marijnkampf commented 8 years ago

Still an issue on some systems.

FlixFlix commented 8 years ago

I think it's time to put Internet Explorer on the shelf and move on to 21st century technologies :)

marijnkampf commented 8 years ago

@FlixFlix unfortunately IE is the only recent WebBrowser version that can be integrated with C#. There are components for Chrome and Firefox but the latest releases I could find when testing for RPS where 4+ years old.

FlixFlix commented 8 years ago

I guess I'm confused why a desktop application needs to rely on an internet browser at all.

marijnkampf commented 8 years ago

It saved me as a developer lots of time as I could use existing technologies like HTML, CSS and JavaScript to handle all the display. A browser as IE includes rendering of a large range of image and video formats out of the box. None of my test systems had any problems with choppy playback, which unfortunately I didn't anticipate.

FlixFlix commented 8 years ago

It's really not just the video playback issue. Transitions aren't smooth either. This is especially noticeable with the Ken Burns pan/zoom effect. One CPU thread is always at 100%, and the cooling fan gets louder, too. Tried on three different systems, three different OSes (Windows 10, 8, and 7). Two of the systems have i7-4770k CPUs.

marijnkampf commented 8 years ago

Pan and zoom runs at less than 3 - 4% CPU on my system. Transitions run at less than 20% (most around 11%). Win 7 64 bit, i7-4770 @ 3.50GHz. Unfortunately it's really difficult for me to test not having access to a system that displays the issue.

Could you try disabling video smoothing in Windows Media Player settings? Are you playing the videos from local stored file or network?

alrpereira commented 7 years ago

Has this been resolved? I have recently installed RPS, and I am having the same problem (choppy transitions & video). My system: Win 10 64bits, AMD FX-8320 eight-core 3.5GHZ, 8GB RAM.

marijnkampf commented 7 years ago

Unfortunately I've not been able to reproduce the issue on any of my machines, which means I haven't been able to fix the issue.