mpv icon indicating copy to clipboard operation
mpv copied to clipboard

First screenshot to a networked folder with a lot of screenshots takes very long

Open HaxtonFale opened this issue 1 year ago • 3 comments

Important Information

Provide following Information:

  • mpv version: v0.37.0-268-ga45518cf
  • Windows Version: 10 Pro 22H2
  • Source of the mpv binary: updater
  • If known which version of mpv introduced the problem: unknown
  • GPU model, driver and version: GTX 1080 (31.0.15.3742)

Reproduction steps

  1. Prepare a networked drive with a screenshots directory.
  2. Ensure it has the first 2000 or so valid screenshot names.
  3. Open mpv with a video file.
  4. Take a screenshot.

Expected behavior

The screenshot is nearly instantaneous.

Actual behavior

The application locks up for almost 30 seconds (buffering any additional inputs) while taking the first screenshot. Every subsequent one is nearly instantaneous, as expected.

Log file

This is the log file for a remote location: screenshots.log

This is one for the same folder, copied locally: screenshots-local.log

HaxtonFale avatar Feb 09 '24 11:02 HaxtonFale

It's tagged as os:win but there's no guarantee it's a Windows-exclusive issue; it's just the only platform I have set up that experiences it.

HaxtonFale avatar Feb 09 '24 11:02 HaxtonFale

This happens because mpv tries to first save mpv-shot0001.jpg, finds that the file already exists, then tries mpv-shot0002.jpg and so on until it reaches a filename that doesn't already exist. The problem is that the networked drive is slow enough that this process repeated 2000+ times takes 30 seconds. I wonder if there's optimizations left on the table for this.

A simple fix would be to include the current filename or timestamp to the screenshot-template.

llyyr avatar Feb 09 '24 11:02 llyyr

A quick check in powershell says I can get the directory contents in about 300ms; since the player caches the last number used anyway (because subsequent screenshots are nigh-instant as expected), why not try that to get a good starting point?

HaxtonFale avatar Feb 09 '24 11:02 HaxtonFale