Skip to content

DarwinAwardWinner/transfercoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Transfercoder: Transfer and transcode your music

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:

  • Assume that I want to transcode everything into a single format, even though the device supports multiple formats.
  • Handle tags incorrectly/not a all during transcoding
  • Require importing my music into a large, complicated media player

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.

Installation

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.

Usage

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.

Prerequisites

  • Python 3 with the plac, mutagen, ffmpy, and tqdm modules installed. (These packages should get installed automatically if you use pip to install Transfercoder.) Python 2 is not supported.
  • My other package, rganalysis, which is used for manipulating ReplayGain tags. This is not on PyPI, so it must be installed manually before installing transfercoder.
  • ffmpeg - For transcoding (Make sure ffmpeg is complied with support for encoding and/or decoding the formats you require)
  • Rsync (optional) - For faster copying of small changes

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.

Limitations

  • You can only choose one target transcoding target format. I can't see a reason you would want more than one. You wouldn't want to transcode flac to ogg and then transcode wavpack to mp3.
  • No playlist support. Obviously, if your playlist has "music.flac" in it and you're transcoding flac to ogg, then your playlist now refers to a nonexistent file in the destination, unless you adjust to the new file name "music.ogg". Playlists are complicated. They may have relative or absolute paths, and devices may expect them in odd formats. You'll need to come up with your own solution here, or just use a media player that handles them.
  • Transfercoder intentionally avoids copying replaygain tags when transcoding. This is because in my experience, different formats of the same song need different replaygain adjustments, even though in theory they should have identical volumes. Instead, just add replaygain tags to your transcoded library on your device after syncing. I have also written a tool for that called rganalysis.

About

Transfer and transcode your music at the same time

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages