Anjok07 / ultimatevocalremovergui

GUI for a Vocal Remover that uses Deep Neural Networks.
MIT License
16.5k stars 1.24k forks source link

Feature Request: Automatically Copy Song Metadata + Filename #394

Open ensingerphilipp opened 1 year ago

ensingerphilipp commented 1 year ago

Hi there!

I think it would be awesome if UVR automatically copies over the Song Metadata like Artist Album and Title to the generated outputs. What would also be cool is if the naming scheme of the outputfiles could be changed - currently it is 1FILENAME(vocals) Better imo would be "FILENAME (vocals_1)" or something along these lines. Instead of completely changing the naming scheme - a customization option that allows you to to sepcify a namingscheme that preserves the original filename more could also be thinkable.

Why this you might ask

When using Karaoke Software that automatically downloads .lrc from Musixmatch or tries to match lyrics from other sources - in the current state of things with the naming scheme being kind of weird and metadata not being copied this often fails and does nto find the lyrics until the file is renamed accordingly.

kristianfreeman commented 6 months ago

Having the same issue, would love for this to land. In the meantime, I'll share a quick script I worked up to handle this locally:

Your files should be structured in the following way:

- Directory with original files
  - 01.flac
  - 02.flac
  - (etc)
  - Instrumental
    - 1_01_(Instrumental).flac
    - 2_02_(Instrumental).flac
    - (etc. - all instrumental files generated by Ultimate Vocal Remover)
    - metadata.sh (below script, can be named whatever)

tl;dr - Create an Instrumental folder and process all of your files into that directory using Ultimate Vocal Remover. Drop the below script into that folder, make it executable (chmod +x metadata.sh), and run it from that directory (./metadata.sh).

#!/bin/bash

# Loop over all files in the current directory with the format "{number}_{filename}_(Instrumental).flac"
for file in *.flac; do
    # Extract the filename without the number and '(Instrumental)' part
    filename=$(echo "$file" | sed -E 's/^[0-9]+_(.*)_\(Instrumental\)\.flac/\1/')

    # Construct the path of the matching file in the parent directory
    parent_file="../${filename}.flac"

    # Check if the parent file exists
    if [ -f "$parent_file" ]; then
        # Copy the metadata from the parent file to the current file
        # Requires 'ffmpeg' to be installed
        ffmpeg -i "$file" -i "$parent_file" -map 0 -map_metadata 1 -c copy "temp_$file"
        mv "temp_$file" "$file"
    else
        echo "Matching file for '$file' not found in parent directory."
    fi
done

filebot -rename *.flac --format "{artist} - {album} - {pi.pad(2)} - {t}" --db ID3

I've added an optional part at the bottom that you can uncomment that uses filebot to cleanly rename the files into the format (artist) - (album) - (track number) - (track), but it does require a license for filebot. You can probably do this with other tools or just rename it manually as well.