tuffy / python-audio-tools

A collection of audio handling programs which work from the command line.
http://audiotools.sourceforge.net
GNU General Public License v2.0
249 stars 58 forks source link

Utility to automatically merge gapless tracks #63

Open SeeSpotRun opened 8 years ago

SeeSpotRun commented 8 years ago

Some music players are limited to mp3 format files, which generally don't handle gapless playback well. One workaround for playing gapless content seamlessly on these devices is to merge gapless files into a single mp3 track. The existing trackcat utility isn't really set up for this case without significant manual input.

I wrote a quick concept at https://gist.github.com/SeeSpotRun/bcc5f415f897ad9914dc which scans files in a folder, detects which tracks have gapless transitions (based on lack of silence at the end of the track), and writes the converted mp3 files to an output folder.

The question is whether to develop this up to a stand-alone utilitity, or to incorporate it as an option in either trackcat or track2track. I had a quick look at the latter option but it looked like it was going to get messy...

SeeSpotRun commented 8 years ago

I managed to crudely incorporate this option into track2track (but probably broke a few things along the way): https://github.com/SeeSpotRun/python-audio-tools/tree/feature/track2track-merge-gapless. Edit: usecase example:

$ track2track /mnt/Music/"Abbey Road"/*.flac  -d /mnt/Music/converted/ -t mp3 --merge-gapless

[ 1/10]  /mnt/Music/Abbey Road/05 Octopus's Garden.flac -> /mnt/Music/converted/05 - Octopus's Garden.mp3
[ 2/10]  /mnt/Music/Abbey Road/04 Oh! Darling.flac -> /mnt/Music/converted/04 - Oh! Darling.mp3
[ 3/10]  /mnt/Music/Abbey Road/02 Something.flac -> /mnt/Music/converted/02 - Something.mp3
[ 4/10]  /mnt/Music/Abbey Road/03 Maxwell's Silver Hammer.flac -> /mnt/Music/converted/03 - Maxwell's Silver Hammer.mp3
[ 5/10]  /mnt/Music/Abbey Road/01 Come Together.flac -> /mnt/Music/converted/01 - Come Together.mp3
[ 6/10]  /mnt/Music/Abbey Road/07 Here Comes the Sun.flac -> /mnt/Music/converted/07 - Here Comes the Sun.mp3
[ 7/10]  /mnt/Music/Abbey Road/08 Because.flac -> /mnt/Music/converted/08 - Because.mp3
[ 8/10]  /mnt/Music/Abbey Road/06 I Want You (She's So Heavy).flac -> /mnt/Music/converted/06 - I Want You (She's So Heavy).mp3
[ 9/10]  /mnt/Music/Abbey Road/14 Golden Slumbers.flac
        +/mnt/Music/Abbey Road/15 Carry That Weight.flac
        +/mnt/Music/Abbey Road/16 The End.flac -> /mnt/Music/converted/14 - Golden Slumbers++.mp3
[10/10]  /mnt/Music/Abbey Road/09 You Never Give Me Your Money.flac
        +/mnt/Music/Abbey Road/10 Sun King.flac
        +/mnt/Music/Abbey Road/11 Mean Mr. Mustard.flac
        +/mnt/Music/Abbey Road/12 Polythene Pam.flac
        +/mnt/Music/Abbey Road/13 She Came In Through the Bathroom Window.flac -> /mnt/Music/converted/09 - You Never Give Me Your Money++++.mp3

If anyone else finds this useful I can put a bit more effort into it, otherwise it's working as-is for what I want.