Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file open fails when filepath is too long #10025

Closed
WaiYanMyintMo opened this issue Mar 28, 2022 · 14 comments
Closed

file open fails when filepath is too long #10025

WaiYanMyintMo opened this issue Mar 28, 2022 · 14 comments
Labels

Comments

@WaiYanMyintMo
Copy link

WaiYanMyintMo commented Mar 28, 2022

Important Information

  • mpv 0.34.0-235-g84821dbcb6
  • Windows 10.0.19041
  • Source of the mpv binary shinchiro
  • 0.33.0 and 0.34.0. could be earlier

Reproduction steps

Try to reproduce your issue with --no-config first. If it isn't reproducible
with --no-config try to first find out which option or script causes your issue.

--no-config doesnt work. Still bad.

Describe the reproduction steps as precise as possible. It's very likely that
the bug you experience wasn't reproduced by the developer because the workflow
differs from your own.

"C:\super long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long filepath.mkv" (length 306)

is the file path.

Expected behavior

Command mpv "Reincarnated Assassin - S01E01 - Quantum Of Trust.mkv" works.

Actual behavior

It doesn't work.

[file] Cannot open file 'Reincarnated Assassin - S01E01 - Quantum Of Trust.mkv': Invalid argument
Failed to open Reincarnated Assassin - S01E01 - Quantum Of Trust.mkv.

or with -v

[file] Cannot open file 'Reincarnated Assassin - S01E01 - Quantum Of Trust.mkv': Invalid argument
[stream] Failed to open Reincarnated Assassin - S01E01 - Quantum Of Trust.mkv.

Log file

output-2.txt

Sample files

Not needed.

Extra information by me

Windows long path is enabled.

When taking the log, I had to use "C:\output-2.txt" because --log-file=output.txt had error [global] Failed to open log file 'output.txt' probably because of the same path length issue.

Double clicking on file explorer kinda works. It loads. Can watch. However, the title property is not correct.
Autoload (autoload.lua) does not work. Probably because of the same issue.

@snylonue
Copy link

snylonue commented Mar 29, 2022

mpv "\\?\D:\longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong
longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglo
nglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong\super long long long long long
long long long long long long long long  long long long long long long long long long long long long l
ong long  long long long long long long long long long long long long long long  long long long long l
ong l.mp4"
 (+) Video --vid=1 (*) (h264 1920x1080 23.976fps)
 (+) Audio --aid=1 --alang=jpn (*) (aac 2ch 44100Hz)
AO: [wasapi] 44100Hz stereo 2ch float
VO: [gpu-next] 1920x1080 yuv420p
(Paused) AV: 00:00:00.000 / 00:02:30.150 (0%) A-V:  0.000 DS: 2.000/0
Saving state.

Exiting... (Quit)

Try adding \\?\ before the absolute path.

@stax76
Copy link
Contributor

stax76 commented Mar 29, 2022

I looked at the manifest and found that it's not set to be long path aware.

https://github.com/mpvnet-player/mpv.net/blob/main/src/MpvNet.Windows/app.manifest

@WaiYanMyintMo
Copy link
Author

mpv "\\?\D:\longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong
longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglo
nglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong\super long long long long long
long long long long long long long long  long long long long long long long long long long long long l
ong long  long long long long long long long long long long long long long long  long long long long l
ong l.mp4"
 (+) Video --vid=1 (*) (h264 1920x1080 23.976fps)
 (+) Audio --aid=1 --alang=jpn (*) (aac 2ch 44100Hz)
AO: [wasapi] 44100Hz stereo 2ch float
VO: [gpu-next] 1920x1080 yuv420p
(Paused) AV: 00:00:00.000 / 00:02:30.150 (0%) A-V:  0.000 DS: 2.000/0
Saving state.

Exiting... (Quit)

Try adding \\?\ before the absolute path.

@snylonue

It works, thanks. Sorry for the late reply, I did not think this would get any traction.

Here is a few things I've noticed

  • if Current Working Directiory is >~260 char, mpv.exe, or any executable (eg. vim) gets launched in a new console window
  • mpv "\?\longfolder*" works well enough for playlists, but of course, autoload still doesn't work
  • the above method also solves the "title" issue I mentioned. It seems to be triggered when directly double clicking from file explorer, which sets the title as "SUPERL~1.MKV" for say, "super long file name.mkv".

This sets the foundation for many workarounds, thanks. Till now I just shortened the folder name of my downloads, which is still very effective and easy and autoload works. Might just continue with that.

@cheater
Copy link

cheater commented Dec 19, 2023

@haasn @pigoz @Dudemanguy @kasper93 could you please reopen this? While prefixing paths with \\?\ is a good workaround, it's not a solution: the program should still be able to handle long file paths. If opening a path fails, the exception handler should retry once with \\?\ prefixed, if that is not present yet. Ultimately the manifest should be made long path aware.

I keep running into this issue constantly and it's just annoying to deal with...

Thanks

@stax76
Copy link
Contributor

stax76 commented Dec 19, 2023

Pull Request: #13134

@cheater
Copy link

cheater commented Dec 19, 2023

@stax76 wow, thank you for such a quick commit! as soon as an .exe is available, I'll try it out and tell you if it worked - are there any builds other than release builds? is there some sort of head build available? thanks

@cheater
Copy link

cheater commented Dec 19, 2023

(ps @WaiYanMyintMo would you mind reopening while this issue is being worked on? thank you!)

@stax76
Copy link
Contributor

stax76 commented Dec 19, 2023

There are auto builds for pull requests, but they are waiting for approval from a maintainer.

See here:

https://github.com/mpv-player/mpv/actions

@cheater
Copy link

cheater commented Dec 19, 2023

Thanks! Yeah, I went browsing and just noticed that :) not used to github as a build server, but I can see the artefacts are available there. TY

@cheater
Copy link

cheater commented Dec 19, 2023

There are auto builds for pull requests, but they are waiting for approval from a maintainer.

See here:

https://github.com/mpv-player/mpv/actions

reading the contribute.md file, I think that would be @rossy or @jeeb?

@stax76
Copy link
Contributor

stax76 commented Dec 19, 2023

Meanwhile, you could test if everything works in mpv.net:

https://github.com/mpvnet-player/mpv.net/releases/tag/v7.0.0.4-beta

I believe it does, which makes it likely it would also work in mpv.

@WaiYanMyintMo
Copy link
Author

Thanks for the attention

@WaiYanMyintMo WaiYanMyintMo reopened this Dec 19, 2023
@cheater
Copy link

cheater commented Dec 19, 2023

@stax76 I can confirm that this works - I created a file that cannot be opened in 0.35 (the version bundled with the SMPlayer version I have) but it can be opened with the build artefacts from your PR (also used via SMPlayer). This fixes a long standing issue, thank you!

@Dudemanguy
Copy link
Member

Reading from long paths should work now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants