Hardcore software you got therre. I like it, but it's very confusing. I want to create playlist, how to do that? In moc it was pretty simple.
For a start, any plain text file with the full path name to the files will work..
Or if you just want to play multiple files, put them after each other in the command line, or open them together/drag them onto the window. You can add additional files by holding shift while dropping files onto the window.
Or if you just want to play multiple files, put them after each other in the command line, or open them together/drag them onto the window. You can add additional files by holding shift while dropping files onto the window.
Can I save this playlist in anyway?
@smolseok
create my_list.txt file with list of files
example:
video1.mp4
video2.mp4
video3.mp4
then run:
mpv --playlist=my_list.txt
Leaving a comment here for people who get here through google.
There's support for plaintext lists as discussed in https://github.com/mpv-player/mpv/issues/4184#issuecomment-466781988 but there's also support for M3U and PLS.
The M3U parser is here and here's the important part (at least for me)
if (bstr_eatstart0(&line, "#EXTINF:")) {
bstr duration, btitle;
if (bstr_split_tok(line, ",", &duration, &btitle) && btitle.len) {
talloc_free(title);
title = bstrto0(NULL, btitle);
}
For people without C knowledge this means that
EXTINF:321,Example Artist - Example title
will be properly parsed
The PLS parser DOES NOT support any additional meta information
static int parse_pls(struct pl_parser *p)
{
return parse_ini_thing(p, "[playlist]", "File");
}
Essentially there's a basic ini format parser and this one only looks for keys with a "File*" and ignores other things, like "Title" or "Length" ... So yeah, if you want to inject meta info then format it as an M3U file.
I'll probably follow this up with an example since I'm about to write one right after I press this green button below
ok so here's an example. Pretend you want a playlist from youtube-dl:
$ youtube-dl -g --get-duration --get-filename https://somesite/somepath
And want to convert it to an m3u parsable by mpv, here's one way to do it
ytdl2m3u.awk
{
switch (NR % 3) {
case 2: title=$0; break
case 1: file=$0; break
case 0:
split($0, parts, ":")
duration = parts[1] * 60 + parts[2]
print "#EXTINF:" duration "," title "\n" file "\n"
break
}
}
so now you can do this:
$ youtube-dl -g --get-duration --get-filename https://somesite/somepath | awk -f ytdl2m3u.awk > something.m3u
And then finally
mpv --term-playing-msg='\n${media-title}' something.m3u
and thus preserve the titles.
As an aside if you want mpv to exit immediately on error there's no simple command line way to do it but it can be done in lua. Let's just presume the exit code of 2 for an error here
quit-on-error.lua
local os = require 'os'
mp.enable_messages('error')
function lg(e)
if e.level == "error" then
print("Exiting...")
os.exit(2)
end
end
mp.register_event("log-message", lg)
so now you can do
$ mpv --script=quit-on-error.lua --term-playing-msg='\n${media-title}' something.m3u
We'll if you're like me have multiple folders you can do this
from the root folder run:
find ./ -type f | sort > pl.txt
then
mpv --playlist=pl.txt
This should work as well:
find ./ -type f | sort | mpv --playlist=-
This should work as well:
find ./ -type f | sort | mpv --playlist=-
Which is the same as mpv ./
Because ./ is just an example for find
Most helpful comment
@smolseok
create
my_list.txtfile with list of filesexample:
then run:
mpv --playlist=my_list.txt