Transfer and transcode your music at the same time
This script is my answer to the common problem of wanting to put one's music library onto a device that doesn't support some of your music formats. All the solutions that I've seen to this problem have at least one of the following drawbacks:
So I wrote my own script to do it. You specify your music directory and the device's music directory, as well as the file extensions that require transcoding and the format to transcode to. All your music is copied to the device, preserving the directory structure. Any files with the specified extensions are transcoded, keeping the same base name and changing the extension. All other files are copied with no modification. This includes all other files, not just other music files. So your album art and stuff gets transferred too. Transcoding happens in parallel if you have multiple cores avilable. Running the same script a second time will only update files that have changed in your music directory. The default transcoding options will transcode several lossless formats to ogg.
In order to know when a source file has been updated, this script
saves the first 32 bytes sha256 hash of the source file in the
transfercoder_src_checksum
tag in each transcoded destination file.
This means that simply changing the time stamps of files in your music
directory will not cause them all the be transcoded again. If you
don't want this, then use the --no-checksum-tags
option, and it will
avoid adding these tags and instead rely on the file time stamps,
transcoding a file any time the source file is newer.
Transfercoder is structured as a Python package, so you can install it
using pip. You must also install another package of mine, rganalysis,
since it isn't on PyPI. Make sure you are installing using a pip
command associated with Python 3, not Python 2. This command may be
named pip3
instead of pip
.
pip install \
https://github.com/DarwinAwardWinner/rganalysis/archive/master.zip \
https://github.com/DarwinAwardWinner/transfercoder/archive/master.zip
This should install Transfercoder and all the other Python packages
that it depends on. After this, you should now have a command called
transfercoder
in your $PATH
.
Once you have installed Transfercoder, you can use it like this:
transfercoder /home/yourname/Music /media/musicplayer/music
This command will copy your music from the first path to the second while transcoding lossless formats like FLAC in the source path to Ogg Vorbis files in the destination using ffmpeg.
See the help (transfercoder --help
) for more options.
As indicated, rsync is an optional dependency. It is primarily useful if you changed only file tags on files that do not require transcoding, in which case there will only be a small difference to transfer.