Coder Social home page Coder Social logo

Comments (6)

kamiyaa avatar kamiyaa commented on June 12, 2024 1

Interesting. I will need to look into this

from joshuto.

kamiyaa avatar kamiyaa commented on June 12, 2024 1

I added the following to memo.lua script:

function get_full_path()
    local path = mp.get_property("path")
    if path == nil then return end

    -- additions
    print("file_path")
    print(path)
    print("working-directory")
    print(mp.get_property("working-directory", ""))
    print("$PWD")
    print(os.getenv("PWD"))
    print("pwd command output:")
    local t = os.execute("pwd")

When I tested it with a video file via mpv, I got the following output:

[memo] file_path
[memo] abc_video.mp4
[memo] working-directory
[memo] /home/kamiyaa/builds/joshuto
[memo] $PWD
[memo] /home/kamiyaa/builds/joshuto
[memo] pwd command output:
/home/kamiyaa/videos
AO: [alsa] 48000Hz stereo 2ch float
VO: [gpu] 1920x1080 yuv420p

So joshuto is correctly setting the current directory within the process (as pwd command output shows)
However, mpv's mp.get_property("working-directory", "") is still returning the incorrect path.
Looking into mpv 's code on how it determines its current directory, its becomes clear that they read a PWD environment variable which joshuto does not set. [3]
I'm not sure if its unix tradition to set the PWD variable, but I imagine setting this variable before running mpv should resolve it.

Weird that this is the way mpv determines its current directory.

Another solution is to unset the PWD variable and force mpv to use the getcwd() function. [3]

EDIT:
it looks like ranger and potentially other file managers set the PWD env var properly

[memo] file_path
[memo] /home/kamiyaa/videos/abc_video.mp4
[memo] working-directory
[memo] /home/kamiyaa/videos
[memo] $PWD
[memo] /home/kamiyaa/videos
[memo] pwd command output:
/home/kamiyaa/videos

References
[1] https://github.com/mpv-player/mpv/blob/1608059d64532e0461e3bec09b20a71802dcb2aa/player/command.c#L3939
[2] https://github.com/mpv-player/mpv/blob/3bdf702b1de8b0d0e0fb700b234b0fc69e04a630/player/command.c#L3192
[3] https://github.com/mpv-player/mpv/blob/master/options/path.c#L327

from joshuto.

kamiyaa avatar kamiyaa commented on June 12, 2024 1

@xfzv Let me know if fd188e9 fixes it

from joshuto.

kamiyaa avatar kamiyaa commented on June 12, 2024 1

Closing!

from joshuto.

xfzv avatar xfzv commented on June 12, 2024

Also breaks oltodosel/mpv-scripts/total_playtime.lua.

The total playtime of current playlist cannot be calculated (returns 00:00:00 (inf%)) unless joshuto was started from the video directory.

from joshuto.

xfzv avatar xfzv commented on June 12, 2024

Yes, it does.

from joshuto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.