Skip to content

Conversation

@ahsand97
Copy link
Contributor

@ahsand97 ahsand97 commented Jul 2, 2025

Sorry for the amount of PRs created for such small changes but this one is to ensure that the thumbnailer would work for files with .aiff extension and .AIFF (capitalized) extension.

@ahsand97 ahsand97 changed the title Another improvement to aiff thimbnailer Another improvement to aiff thumbnailer Jul 2, 2025
@clefebvre
Copy link
Member

Merging..

however, I couldn't find any .aiff files with cover art online. What's the use case for this?

Also, I noticed many of these files have an .aif extension, not .aiff.

@clefebvre clefebvre merged commit ea7277f into linuxmint:master Jul 22, 2025
1 of 2 checks passed
@ahsand97
Copy link
Contributor Author

ahsand97 commented Jul 22, 2025

Merging..

however, I couldn't find any .aiff files with cover art online. What's the use case for this?

Also, I noticed many of these files have an .aif extension, not .aiff.

.aiff format is a high quality audio format (same as .wav) https://en.wikipedia.org/wiki/Audio_Interchange_File_Format, it is not as used as the .wav format but both are in the same category of lossless quality audio, the difference is that the .aiff format allows to have more metadata than the .wav format, cover art being one of them. I'm a DJ so I have a bunch of tracks with .aiff format and I wanted to be able to see the cover art, that's why I decided to create the aiff-thumbnailer using the python-mutagen library, this is an example of my track collection displaying the thumbnails:

image

@clefebvre
Copy link
Member

Can you add a sample .aiff file with cover art?

Where do you get these files? Where do you download them, or which tool do you use to edit their cover art and generate them under that format?

@clefebvre
Copy link
Member

Regarding the extension:

The file extension for the standard AIFF format is .aiff or .aif. For the compressed format the preferred suffix is .aifc, but audio applications supporting the format also allow .aiff or .aif.

@clefebvre
Copy link
Member

I think you can drop this altogether:

if not filepath.is_file() or not filepath.suffix.lower() == ".aiff":
            return None

The thumbnailer already restricts itself by mimetype audio/x-aiff. There's no need to check the file extension.

@ahsand97
Copy link
Contributor Author

Can you add a sample .aiff file with cover art?

Where do you get these files? Where do you download them, or which tool do you use to edit their cover art and generate them under that format?

Sure, I created my own application to download high quality tracks from sites like YouTube, SoundCloud, bandcamp (using yt-dlp) and I use this function to embed the cover in the track file (.aiff file), also you can get such high quality tracks from different paid platforms like beatport.

def embed_cover_in_track(track_path: Path, cover_path: Path) -> None:
    """Embeds the cover image in the track using mutagen. The track must be in .aiff format and the cover image must be in .png format."""
    try:
        if track_path.suffix != ".aiff" or cover_path.suffix != ".png":
            if debug:
                print(
                    "\nCan't embed the cover in the track, wrong extension for the track or cover. Track must be in"
                    + " .aiff format and cover in .png format"
                )
            return
        if debug:
            print(f'\nEmbedding cover: "{str(cover_path)}" inside the track: "{str(track_path)}"')
        aiff_file: AIFF = AIFF(str(track_path))
        if aiff_file.tags is None:
            aiff_file.add_tags()
        aiff_file.tags.add(  # pyright: ignore[reportUnknownMemberType, reportOptionalMemberAccess]
            frame=APIC(
                encoding=3,
                mime="image/png",  # image/jpeg or image/png
                type=3,  # 3 is for the cover image
                desc="Cover",
                data=cover_path.open(mode="rb").read(),
            )
        )
        aiff_file.save()  # pyright: ignore[reportUnknownMemberType]
        if debug:
            print("    Cover embedded correctly.")
    except Exception as e:
        print("An error occurred embedding the cover to the track.")
        if debug:
            traceback.print_exception(e)

The same functionallity can be achieved using C library taglib

This would be an example of an .aiff file with cover, you can see the cover using audio players like mpv or vlc
https://drive.google.com/file/d/1Vqoo77ZOctxiBBBsBKk9QYG_7_OyTEPL/view?usp=sharing

@ahsand97
Copy link
Contributor Author

I think you can drop this altogether:

if not filepath.is_file() or not filepath.suffix.lower() == ".aiff":
            return None

The thumbnailer already restricts itself by mimetype audio/x-aiff. There's no need to check the file extension.

Got you, I'll create another PR deleting this part to not check the extension.

@clefebvre
Copy link
Member

There might be another issue.. I can get your thumbnailer to work with the indira song when I call it via CLI, but nemo still doesn't generate thumbs for me.

@clefebvre
Copy link
Member

Feel free to add aiff to the readme also.

@ahsand97
Copy link
Contributor Author

There might be another issue.. I can get your thumbnailer to work with the indira song when I call it via CLI, but nemo still doesn't generate thumbs for me.

Hmm do you see any logs if you launch nemo via CLI? I'm using PCManFM-Qt and I can see the thumbnail

@ahsand97
Copy link
Contributor Author

Feel free to add aiff to the readme also.

Done in #19

mtwebster added a commit that referenced this pull request Jul 23, 2025
sys.exit(n) raises a SystemExit exception, which was being caught
by the bare exception handler, causing a failure exit code.

ref: #18 (comment)
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