Ability to add metadata when writing file
See original GitHub issueHey all,
I was working with OGG Vorbis export and needed to add a metadata field to the file (here: OGG Vorbis Comment). I couldn’t see how this was possible with PySoundfile
, so I used the mutagen library instead. It feels a bit hacky to write the file and then read it again to modify the metadata and then save again.
Example:
import soundfile
import mutagen
# Write OGG file
soundfile.write('test_file.ogg', data, sr, format='ogg', subtype='vorbis')
# Read OGG file, add metadata and save again
file = mutagen.File('test_file.ogg')
tags_new = file.tags
tags_new['ARTIST'] = 'TEST ARTIST NAME"
file.tags = tags_new
file.save()
Ideally I think something like this would be handy:
import soundfile
# Write OGG file with metadata
tags_new = dict()
tags_new['ARTIST'] = 'TEST ARTIST NAME'
soundfile.write('test_file.ogg', data, sr, format='ogg', subtype='vorbis', tags=tags_new)
Nothing urgent, but probably a nice feature that could be added at some point. The more annoying part is probably making sure it works for each individual file type, as tags work differently for the different formats (MP3, OGG, WAV,…).
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
How to Add Metadata to Your Image Files - Artwork Archive
Right-click on the image and select “Properties” · In the window that appears, you can change the file name, add tags, write a...
Read more >What is a file's metadata and how to edit it in Windows?
Metadata is information stored in almost any type of file. It can include your name, your company or organization's name, the name of...
Read more >The 7 best metadata editors available in 2021 - Canto
1. MyMeta. MyMeta is a Windows-based system that allows users to edit media file metadata. If you've ever tried to edit metadata manually,...
Read more >How to Add Metadata to Images and Video
Open up the folder on your computer that contains the image or video file. · PC users: Right-click on the image, and select...
Read more >Adding Metadata to Your Images
If you don't use Adobe Lightroom, you can also add metadata to your image file from Adobe Bridge. In the Bridge be aware...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Open a file, use the dict-like accessor to read or write the metadata:
Available fields are:
The feature is not supported for all file types.
You can already edit the following metadata fields: title, copyright, software, artist, comment, date, album, license, tracknumber, and genre, using e.g.
file['artist'] = 'Picasso'
. Beyond that, however, no metadata is accessible through our underlying library, libsndfile.