Number of controllers is not actually the number of controllers, it is a bitfield, generated as such:
for (int i = 0; i < 4; i++)
{
if (SConfig::GetInstance().m_SIDevice[i] == SIDEVICE_GC_CONTROLLER || SConfig::GetInstance().m_SIDevice[i] == SIDEVICE_GC_TARUKONGA)
controllers |= (1 << i);
if (g_wiimote_sources[i] != WIIMOTE_SRC_NONE)
controllers |= (1 << (i + 4));
}
Same with bongos.
Also, can you not simply include the struct from
https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/Core/Movie.h#L60 and then just read the dtm file into that struct? Not sure if c# has a convenient way to do that, since i know nothing about it, but it will pretty much just make everything work automatically, including keeping unknown values (so it doesn't totally break if the format is updated). In c++ reading the file is as simple as
std::ifstream movie;
movie.open(argv[1], std::ios::out | std::ios::binary);
DTMheader header;
movie.read((char*)&header, 0x100);
movie.close();