I don't know about mp3 because I only have high resolution sound source. I want to get FLAC and WAVE tag information (song title and artist). In the mutagen library, the tag information of the wav format music file could not be obtained, so the pytaglib library was used.
windows10 pro 64bit python 3.8.1 64bit
pytaglib is a library that binds a C ++ library called TagLib so that it works from python.
"Manual Compilation: Windows" at the bottom of the formula was implemented below. pytaglib official
Download TagLib and unzip it. (https://taglib.org/#windows)
1. Install Microsoft Visual Studio 2015 Community Edition. In the installation process, be sure to enable C/C++ support. Alternatively, install Visual Studio 2017, but install the "v140" C++ toolset and use the "Visual Studio 2015" version of the developer command prompt below.
I'm using SDK8.1 to build C ++, but I can't install SDK8.1 with Microsoft Visual Studio 2019, so I'll install the old Visual Studio.
Download the current taglib release and extract it somewhere on your computer.
Download TagLib and unzip it. (https://taglib.org/#windows)
Start the VS2015 x64 Native Tools Command Prompt. On Windows 8/10, it might not appear in your start menu, but you can find it here: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts
Execute "VS 2015 x64 Native Tools Command Prompt" from the start menu. ★ There are multiple command prompts, so don't make a mistake!
3. Navigate to the extracted taglib folder and type: cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=".\taglib-install" to generate the Visual Studio project files.
Move to the decompression destination of taglib and execute the following command (*) cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=".\taglib-install"
A "taglib-install" folder will be created in the taglib folder, and the library will be created.
3. Still in the VS2015 command prompt, navigate to the pytaglib directory.
Change to the pytaglib directory on the command prompt in step 2.
4. Tell pytaglib where to find taglib: set TAGLIB_HOME=C:\Path\To\taglib-install
Pass through the C ++ TagLib path created in step 2.
5. Build pytaglib: python setup.py build and install: python setup.py install
Execute the following command to make it available in python.
python setup.py build
python setup.py install
★ If you make a mistake and execute it at another command prompt, you will get angry with "fatal error LNK1112". I got stuck here for a day ...
With this, I finally got the tag information as if it were in the sample! Since flac and wave can be obtained with the same code, I personally felt that it was better than mutagen. However, work is required from the build of TagLib's C ++ library, and there is little information in Japanese, so preparation is difficult.
sample.py
import taglib
song = taglib.File("/path/to/my/file.wave")
print(song.tags)
-mutagen link: available with pip install mutagen. If you don't care about waves, this is enough
Recommended Posts