Skip to content

demux_cue: fix incorrect dirname#17867

Open
MSViswanth wants to merge 2 commits intompv-player:masterfrom
MSViswanth:fix/demux_cue
Open

demux_cue: fix incorrect dirname#17867
MSViswanth wants to merge 2 commits intompv-player:masterfrom
MSViswanth:fix/demux_cue

Conversation

@MSViswanth
Copy link
Copy Markdown

When opening cue files which have audio files in a subdirectory, instead of using the path from the cue file, mpv uses the path where the cue file is openend from. So, it always defaults to ./<filename>.<ext>.

Example

Consider the following Test.cue.

PERFORMER "Blue Deer"
TITLE "Tiny Shell"
FILE "Disc 1/Tiny Shell - Blue Deer, Nyles Lannon.mp3" MP3
  TRACK 01 AUDIO
    TITLE "Tiny Shell"
    PERFORMER "Blue Deer, Nyles Lannon"
    INDEX 01 00:00:00

My directory structure

.
├── Disc 1
│   └── Tiny Shell - Blue Deer, Nyles Lannon.mp3
└── Test.cue

mpv crashes like this.

[file] Cannot open file './Tiny Shell - Blue Deer, Nyles Lannon.mp3': No such file or directory
Failed to open ./Tiny Shell - Blue Deer, Nyles Lannon.mp3.
Could not open source './Tiny Shell - Blue Deer, Nyles Lannon.mp3'!
CUE: No useful audio filename in .cue file found, trying with 'Test.cue' instead!
CUE: Could not open audio file!
File tags:
 Performer: Blue Deer
 Title: Tiny Shell
No video or audio streams selected.
Exiting... (Errors when loading file)

Audio file is from YouTube's Audio Library.

When opening cue files which have audio files
in a subdirectory, instead of using the path from
the cue file, mpv uses the path where the cue file is
openend from. So, it always defaults to './<filename>.<ext>'.
Comment thread demux/demux_cue.c Outdated
bool res = false;

struct bstr dirname = mp_dirname(tl->demuxer->filename);
struct bstr dirname = mp_dirname(filename);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't the right fix, this will break dirname extraction in the opposite direction. That is, cue file is in the same level as the audio file and the CWD isn't the same directory too

@llyyr
Copy link
Copy Markdown
Contributor

llyyr commented May 3, 2026

Please try #17868

mp_basename on filename remove the dirname info from it
@MSViswanth
Copy link
Copy Markdown
Author

Please try #17868

This works. Your change looks a lot cleaner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants