mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.08k stars 2.88k forks source link

How to automatically play DVD or Blu-ray ISO files? #13712

Closed Solarunit closed 1 month ago

Solarunit commented 6 months ago

I figured out how to play DVD or Blu-ray ISO files from the terminal using:

mpv bd:// --bluray-device=[path-to-bluray-iso] for Blu-ray ISO

and

mpv dvd:// --dvd-device=[path-to-dvd-iso] for DVD ISO

The question is how to play those iso files automatically? Like mpv [path-to-iso] will detect if it's DVD ISO or Blu-ray ISO and will play it.

Is there a condition I can put into mpv.conf? Or maybe it's possible with some lua script? Maybe there is already such script?

dyphire commented 6 months ago

For the lua script, you can refer to the relevant implementation in the open_dialog.lua script.

Solarunit commented 6 months ago

@dyphire interesting, I will check it out, thanks.

Solarunit commented 6 months ago

I am new to lua, how to get file path/basename in mpv [file-path]? I am trying mp.get_property(path) without success so far

guidocella commented 6 months ago

mp.get_property('filename')

Solarunit commented 6 months ago

when printing print(mp.get_property('filename')):

nil property unavailable

guidocella commented 6 months ago
mp.register_event('file-loaded', function()
    print(mp.get_property('filename'))
end)
Solarunit commented 6 months ago

it doesn't print anything for me :(

it works! Thanks!

Solarunit commented 6 months ago

with my test lua script I can redirect dvd iso file to

local function open_dvd(path)
    mp.set_property('dvd-device', path)
    mp.commandv('loadfile', 'dvd://')
end

but not for bluray iso :cry:

[file] Opening file.iso
....

[cplayer] Opening failed or was aborted: file.iso
...

[cplayer] finished playback, unrecognized file format (reason 4)

Unlike dvd iso it can't start playback bluray iso file, so we will never get to this point in lua script:

mp.register_event('file-loaded', function()

update: I have some progress with 'start-file' event

mp.register_event('start-file', function()
Solarunit commented 6 months ago

I have some progress with the script. I can redirect bluray iso file to open_bluray(path) function too. What is the proper way to get parent directory of some directory in lua?

Like: path = /dir1/dir2/

and I need to get /dir1/ path