sxyazi / yazi

💥 Blazing fast terminal file manager written in Rust, based on async I/O.

Home Page:https://yazi-rs.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Audio cover preview support

gaesa opened this issue · comments

Please describe the problem you're trying to solve

Without the proposed feature, the current state of audio file navigation in the application is not as intuitive or visually engaging as it could be. Users are only able to view metadata, which may not provide enough visual cues to quickly and easily identify specific audio files. This can lead to a less efficient and enjoyable user experience, especially for those with large collections of audio files with cover art.

Would you be willing to contribute this feature?

  • Yes, I'll give it a shot

Describe the solution you'd like

The proposed solution involves checking if an audio file has a cover using the lofty library in Rust. If a cover is present, it will be used for the preview. If not, the program will fall back to previewing the audio's metadata. Here is a sample code snippet demonstrating this:

use lofty::file::TaggedFileExt;
use lofty::probe::Probe;

fn audio_has_cover<P: AsRef<Path>>(path: P) -> bool {
    return match Probe::open(path) {
        Ok(p) => {
            let tagged_file = match p.read().ok() {
                Some(file) => file,
                None => return false,
            };
            let tag = match tagged_file.primary_tag() {
                Some(tag) => tag,
                None => return false,
            };
            tag.picture_count() > 0
        }
        Err(_) => false,
    };
}

If the audio file has a cover, the following ffmpeg command can be used to generate the thumbnail:

[
    "/usr/bin/ffmpeg",
    "-i",
    audio,
    "-an",
    "-vcodec",
    "copy",
    thumbnail_path,
]

Additional context

No response

Hi, https://github.com/Sonico98/exifaudio.yazi is exactly what you're looking for:

302044743-53c1492c-9f05-4c80-a4e7-94fb36f35ca9

You can find more awesome plugins at https://yazi-rs.github.io/docs/resources

I'm going to lock this issue because it has been closed for 30 days. ⏳
This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.