3

For example, these types of .SPC files: random SPC and WAV folder

I don't want it to bring a window in the foreground, just an invisible process that will convert an SPC to a WAV.

executable foo/bar/input.spc bar/foo/output.wav

I'm using this in a command-line Java application, so a Java solution would be appreciated if possible. (I can use ProcessBuilder to run the executable if not.)

1 Answer 1

4
+150

How convenient! FFMPEG can read and convert SPC files!

ffmpeg -i night1.spc -acodec pcm_u8 -ar 44100 night1.wav

Now, this command will convert your file pretty cleanly, and will spit out a nice .wav file (be sure to replace night1.spc and night1.wav with whatever you want the filenames to be).

Unfortunately, this does not end the story in the slightest. After running the above command for a while, I got the following result:

-rw-rw-r-- 1 kazwolfe kazwolfe 297M Mar 28 02:05 night1.wav
-rw-rw-r-- 1 kazwolfe kazwolfe  65K Mar 28 02:01 night1.spc

This can't be right... let's pop open the file in Audacity and see what's going on:

In short, SPC files don't have a length defined in them. While there is a mention of length in the spec, it seems to be often ignored, and actually is ignored in the files uploaded to your Google Drive.

SPC files, as ripped from the SNES (in its original format) were meant to loop pretty much forever. As such, when they're played (or converted in this case), they're going to also loop forever.

So, we need to manually pass in the length (and possibly offset) to ffmpeg. Fortunately, the program comes with a cool little command line argument called -t <time>. Using this, we can specify how much audio we want to convert.

Similarly, if the file has an offset, we can use the -ss <time> argument to specify how far from the beginning we want to clip.

Therefore, assuming a 45 second file with an offset of 5 seconds, the command we need to run is:

ffmpeg -i night1.spc -t 00:00:45 -ss 00:00:05 -acodec pcm_u8 -ar 44100 night1.wav
7
  • Any way we can get the time of a loop from the SPC?
    – Aly
    Mar 28, 2017 at 12:08
  • Besides it being encoded in the ID666 tags, I can't see anything other than going in and manually reading the file. I'm sure this can be programmatically done (e.g. you can see how large the data block of the file is, and then compute approximately how long the loop is that way), but I have been able to find no resources for how to do that. If your SPC files did have sound data, it would be stored in the highlighted data block and be readable by vSNES or any other memory editor (see picture).
    – Kaz Wolfe
    Mar 28, 2017 at 18:02
  • SPC700 plays these for two loops and then fades over 5 seconds. Is there a way to specify that? @KazWolfe
    – Aly
    Mar 31, 2017 at 23:31
  • @moo_we_all_do If you know the loop length time, sure. As for fade, I think FFMPEG has an option for that. See man ffmpeg, as I'm honestly not sure what said option is.
    – Kaz Wolfe
    Mar 31, 2017 at 23:34
  • Nice! I'll definitely be using this. (Sorry for more questions but) is there any way to stream this with sedmelluq/lavaplayer and Discord4Java? I guess if I stream it I can see when it hits the end of a loop?
    – Aly
    Apr 3, 2017 at 14:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .