mpv-playlistmanager icon indicating copy to clipboard operation
mpv-playlistmanager copied to clipboard

Can resolve_titles also work on local file?

Open kesdoputr opened this issue 4 years ago • 5 comments

I have set prefer_titles = "all" resolve_titles = true

I have some mp3 with filename Track01 Track02....etc and they have titles. Now it seems only the playing file will show the title. Other file will show the filename until they are played. Is it possible to resolve title also for local file like for url?

Thanks for your reading.

kesdoputr avatar May 31 '20 14:05 kesdoputr

I think this is currently not trivial since mpv doesn't load files before they are played. So the lua API doesn't have access to the titles, they are only cached once the file has been loaded.

It could be possible to run a subprocess to fetch the title metadata with some program but it easily gets messy. I'm not aware of a way to do it with the mpv binary. Perhaps ffmpeg could do it.

jonniek avatar Jun 02 '20 12:06 jonniek

OK, i undestand, thanks for your reply ^^

kesdoputr avatar Jun 02 '20 15:06 kesdoputr

Let's keep this open since it's a nice feature. Hopefully someone can come up with a good solution for this.

jonniek avatar Jun 03 '20 08:06 jonniek

mediainfo has a Movie name field in its output.

FichteFoll avatar Jun 04 '20 21:06 FichteFoll

ffmpeg seems to be able to do it with the following command: ffmpeg -f ffmetadata pipe:1 -hide_banner -loglevel warning -i [filename].

An example of the output to stdout:

;FFMETADATA1
album=Ghost Hound Original Soundtrack
artist=TENG
date=2007
genre=Soundtrack
title=Awake
track=1
encoder=Lavf58.45.100

The title should be easily extractable using string.match(stdout, "title=([^\n\r]+)")

Alternatively, it may be better to use ffprobe, which is bundled with ffmpeg and seems better designed for this. ffprobe -show_format -show_entries format=tags -print_format ini -loglevel warning [filename] provides a similarly parsable output with the added advantage of escaping newlines:

# ffprobe output

[format]
[format.tags]
album=Ghost Hound Original Soundtrack
artist=TENG
encoder=Lavf57.36.100
genre=Soundtrack
title=Awake
track=1
creation_time=reation_time
date=2007

CogentRedTester avatar Feb 01 '21 05:02 CogentRedTester

This has been implemented by @2084x :+1:

jonniek avatar Dec 11 '22 11:12 jonniek