So, I ended up figuring out how to do this with ffmpeg. In case anybody else is wondering at some point, here's how.
Btw: These are 216 files all in one folder, and part of the filename is a sequential number. That made it a bit easier for the DOS looping.
The first thing I did was to create a plain text file, called temps.txt , which has just these two lines in it:
file temp1.mp3
file temp2.mp3
You'll see what that's for in a minute.
Then I wrote a batch file that loops through all the files in the directory (based on the sequential numbering above), and runs two ffmpeg operations on each:
FOR /L %%i IN (1,1,216) DO (
ffmpeg.exe -y -i OriginalFile%%i.mp3 -ss 00:03.81 -to 00:08.83 -acodec copy "temp1.mp3" -ss 00:13.95 -acodec copy "temp2.mp3"
ffmpeg.exe -y -safe 0 -f concat -i temps.txt -c copy NewFile%%i.mp3
)
The first operation grabs the two desired segments and copies them to temp1.mp3 and temp2.mp3 (I kept reusing those same two filenames). ffmpeg allows you to isolate both sections on one command line, which is nice. Also, you may note that the second part only has the -ss
timestamp, and no -to
stamp. That allows it to just use the End of File as the second timestamp.
The second operation tells ffmpeg to look in the temps.txt file and concatenate the two files that are listed there. Reusing the temp file names is why I was able to just have the static temps.txt file that I created above.
I wrote this fairly bluntly (hard-coding the number of files in the directory, reusing temp files, using the -y flag in the command lines), because I knew exactly what I had to work with, and I had a backup of it anyway. If you're repurposing this, you might want to be a little more delicate about those things.
Also, I lost all the metadata in this process. There's probably an easy way to preserve that, but I didn't bother figuring it out. Easy enough for me to just re-add it to the new files all at once (using MP3Tag, one of the greatest utilities of all time).
So, there you have it.
Btw, some links that helped me figure this out:
- I started with ffmpeg - Trim audio file without re-encoding
- Then to fiddle with the specifics I referenced ffmpeg Documentation
- For the concatenation I got a lot from this answer to a Stack Overflow question. The question was about video, which is much more complicated, but this answer told me everything I needed to know about audio as well. Specifically, I used the second method that this answer describes.
- And finally, I didn't really use this one, but there's more useful info about the concat command on this wiki -- including instructions for auto-generating a list file on either Windows or bash.
(Thanks @barlop for the suggestion to add those.)
dir /s/b *.mp3 >filelist.txt