Performance issues in windows

I have been looking at the performance in windows 10 and there seems to be something strange going on.

I have video clips that playback fine and I have re-encoded them to low resolution mjpeg as proxy files so the editing should be very light weight. Currently these are 384x216 MJPEG files at 23.967 fps encoded using the copy of ffmpeg bundled with shotcut. The files playback fine in shotcut on there own.

However if I have a few clips together in a timeline the playback will drop many frames. My current test timeline has 12 clips with a total length of just 1 min 12 seconds. There are no filters applied. All the clips are the same properties.

I am not at all familiar with windows development but this annoyed me enough to find and install the windows performance toolkit. Looking at the playback the cpu only goes up to 30% and there is no load on the i/o that I can see etc. Drilling down most of the shotcut time is spent in “setlocale” which (wild guess) seems to be from the usage of avcodec when using string manipulation to lookup timestamps.

This strange “hot” function in the performance graphs is odd and i would guess should be addressed. However this is probably not the root cause as the cpu usage is fine with lots of room. So why is it skipping frames? As it is windows I am at a bit of a loss as to where to look for what is blocking the playback.

In the image you can see that shotcut (the green line) only goes to around 30% cpu usage. I played for a couple of seconds then paused then played again. The blue filled area corresponds to the selected function in the call stack ie setlocale which was called over 9000 time in around 10 seconds.

Is this the correct forum to discuss this issue or should I take this to github?

OK so… time for an update.

The issue is present with only one video in the playlist. Also its a mlt framework issue (the underlying video manipulation tool) not shotcut (the GUI).

Surprisingly however this is caused by the setlocale() call on windows, where it is very slow. To prove this I removed all calls to setlocale() from the framework (and avfilter plugin). After rebuilding with this applied it all is silky smooth and the cpu usage is down to 10% or lower. On my system there are no side-effects as the call itself does nothing for my setup.

I have posted the patch I used to prove the issue here:

I made an issue in github for this here: