PDA

View Full Version : Exporting - manipulating and reimporting extended flac tags (classical)



Learnincurve
2016-11-18, 01:54
Hi,

I have a collection of flac files, some of long classical operas, which have been converted from dsf. Each track is stored as an individual flac on a Linux system.

In some cases Musicbrainz does have tags, but these are problematic, either listing artists differently, or providing too much information for each track. For example, a Wagner opera might consist of hundreds of tracks, each listing artists in several different formats, roles, technicians, composer and conductor.

In my present collection, I have spent quite a lot of time using qoobar, tidying this information, so as to present the performing artists by standard name only and deleting spurious information. The clean-up is still not complete, but is a lot better than what is available directly from MusicBrainz.

My problem is that now I want to recreate the flacs from dsf at a higher bitrate, as I now have a DAC that will handle 24/176.

Can anyone help me with steps 1 and 4 of the following (needs to be scripted due to large number of files):

1. Go through each directory, exporting all the tags (including extended flac tags and artwork) for every existing .flac in the directory and storing.
2. Delete the flacs
3. Recreate flacs at the higher bitrate (files will be named identically to the way they were before).
4. Retag the new flacs using the stored metadata from step 1.

BR.

--Marius--

d6jg
2016-11-18, 03:42
Hi,

I have a collection of flac files, some of long classical operas, which have been converted from dsf. Each track is stored as an individual flac on a Linux system.

In some cases Musicbrainz does have tags, but these are problematic, either listing artists differently, or providing too much information for each track. For example, a Wagner opera might consist of hundreds of tracks, each listing artists in several different formats, roles, technicians, composer and conductor.

In my present collection, I have spent quite a lot of time using qoobar, tidying this information, so as to present the performing artists by standard name only and deleting spurious information. The clean-up is still not complete, but is a lot better than what is available directly from MusicBrainz.

My problem is that now I want to recreate the flacs from dsf at a higher bitrate, as I now have a DAC that will handle 24/176.

Can anyone help me with steps 1 and 4 of the following (needs to be scripted due to large number of files):

1. Go through each directory, exporting all the tags (including extended flac tags and artwork) for every existing .flac in the directory and storing.
2. Delete the flacs
3. Recreate flacs at the higher bitrate (files will be named identically to the way they were before).
4. Retag the new flacs using the stored metadata from step 1.

BR.

--Marius--

1. In Windows you could use mp3tag to get 1. done - it will export to a csv file on a per directory basis. You would run it from the top level of your music files.
2. is of course easy
3. I can't see any way that you would ever be able to do this unless the dsf files have identical names to the existing FLACs and you have a logical directory/folder structure
4. Not sure

matka
2016-11-19, 07:12
In somehow similar scenarios I've used metaflac tool. You can export all the tags to a file
metaflac --export-tags-to=tagfile.txt someflac.flac and once you have new flac, import it back. I would name exported tag files same as flac save for extension. The automation part you would have to script it, I use Perl for that but I'm sure python or others will do as well.

Roland0
2016-11-20, 10:46
Here's a first stab at a script (bash shell). Since I don't have any DSFs, I can't really test it.


#!/bin/bash
IFS=$'\n'
ECHO="echo"

OLD=oldflac
SRC=dsf
NEW=newflac

for i in `find $OLD -name \*.flac`; do
NF="${i/#$OLD/$NEW}"
ND="`dirname "$NF"`"
SF="${i/#$OLD/$SRC}"
TF="$NF.tag"
PF="$NF.jpeg"
[ \! -d "$ND" ] && $ECHO mkdir -p "$ND"
$ECHO metaflac --no-utf8-convert --export-tags-to="$TF" "$i"
$ECHO dsf2flac -i "${SF%flac}dsf" -o "$NF"
$ECHO metaflac --no-utf8-convert --import-tags-from="$TF" "$NF"
$ECHO rm "$TF"
$ECHO metaflac --export-picture-to="$PF" "$i" 2>/dev/null && $ECHO metaflac --import-picture-from="$PF" "$NF" && $ECHO rm "$PF"
done


Note:
- You need two folders: oldflac contains the existing flacs, dsf the source DSFs. The folder/file structure has to be exactly the same (eg oldflac/artist1/song1.flac -> dsf/artist1/song1.dsf etc.)
- adjust the dsf2flac command with the relevant parameters
- new flacs will be in folder newflac
- Not really sure if it actually works, so there is a safety mechanism: As it is, the script will just output the commands, not execute them. Test it, and if you are sure the commands are correct, change the line


ECHO="echo"

to


ECHO=""

and test it on a small sample which has a backup

matka
2016-11-21, 18:12
Here's a first stab at a script (bash shell). Since I don't have any DSFs, I can't really test it.


#!/bin/bash
IFS=$'\n'
ECHO="echo"

OLD=oldflac
SRC=dsf
NEW=newflac

for i in `find $OLD -name \*.flac`; do
NF="${i/#$OLD/$NEW}"
ND="`dirname "$NF"`"
SF="${i/#$OLD/$SRC}"
TF="$NF.tag"
[ \! -d "$ND" ] && $ECHO mkdir -p "$ND"
$ECHO metaflac --no-utf8-convert --export-tags-to="$TF" "$i"
$ECHO dsf2flac -i "${SF%flac}dsf" -o "$NF"
$ECHO metaflac --no-utf8-convert --import-tags-from="$TF" "$NF"
$ECHO rm "$TF"
done

and test it on a small sample which has a backup
What a great and concise sample !

Perhaps you could also add picture export/import, I believe OP asked for that as well.


metaflac --export-picture-to=
metaflac --import-picture-from=


There is also the problem of lyrics (if any), they export as multi lines and import does not handle them as each line should start with a tag name. I usually remove them...

Learnincurve
2016-11-22, 05:16
What a great and concise sample !

Perhaps you could also add picture export/import, I believe OP asked for that as well.


metaflac --export-picture-to=
metaflac --import-picture-from=


There is also the problem of lyrics (if any), they export as multi lines and import does not handle them as each line should start with a tag name. I usually remove them...

Absolutely perfect!

Thanks all for the excellent discussion, leading to exactly what I was looking for!!

BR.

Roland0
2016-11-22, 08:12
Perhaps you could also add picture export/import, I believe OP asked for that as well.

I've added it to the original script



There is also the problem of lyrics (if any), they export as multi lines and import does not handle them as each line should start with a tag name. I usually remove them...

I may have a solution if the assumption that the LYRICS tag is always the last in the export file holds true (not 100% sure about it, obviously)
However, unless specifically requested, I won't add it as it would make the script even more likely to break.