axeldelafosse / stemgen

🎛 Stemgen is a Stem file generator. Convert any track into a Stem and have fun with Traktor.
https://stemgen.dev
MIT License
207 stars 39 forks source link

Generated file has wrong file extension .stem.m4a instead of .stem.mp4 #47

Closed JoergAtGithub closed 4 months ago

JoergAtGithub commented 5 months ago

A STEM file must have the suffix .stem.mp4, but stemgen generates the file with the extension .stem.m4a.

Traktor Pro seems not to care for the file extension and loads it anyway, but for other tools it makes a difference. The .mp4 extension is selected by Native Instruments, because any MP4 decoder will play the master track with all stems mixed when the file is loaded.

axeldelafosse commented 4 months ago

Hello Joerg,

.m4a is the same as .mp4 -- it simply means that it only contains audio (and no video).

You can easily change this is the code if you prefer .mp4 extensions instead.

Thank you for using Stemgen!

JoergAtGithub commented 4 months ago

This violates not only the specification of the STEM format, it also breaks third party players like VLC, which do not play STEM files extension .m4a, but with extension .mp4.

axeldelafosse commented 4 months ago

Can you link to the specification please?

JoergAtGithub commented 4 months ago

You have to register at Native Instruments to get it: https://www.stems-music.com/stems-is-for-developers/

axeldelafosse commented 4 months ago

So I guess you are referring to this part:

"There are two criteria every Stem File must fulfill—failure to fulfill these criteria means the file in question is not a Stem File: ▪ The file must be a valid MP4 file (ISO base media file format: ISO/IEC 14496-12) with the “.mp4” file extension. Preferably the file name should end with “.stem.mp4”, but just “.mp4” is also valid. ▪ The MP4 file must contain a box (i.e. data container) of type stem as a sub-box of moov.udta. moov is the root box of the MP4 file, as shown in the Stem File Structure diagram in section ↑7.1, File Structure."

But this repo is a fork of ni-stem (included in the SDK you linked) and if you look at the code, it is actually using .m4a for the file extension: stemOutExtension = ".m4a".

So now you might argue that Native Instruments isn't following its own specification, but I don't really have time for this. The important part is that the file is a valid MP4 file.

I'm sorry if you have some trouble playing the Stem files with VLC but it's working for me on macOS and Windows (it's even displaying the cover pretty nicely on Windows). The issue is probably coming from somewhere else.

And again, feel free to patch the code in ni-stem to use .mp4 if .m4a isn't working for you. This is why this repo is open-source!