Bone rotation keyframe registration

I’ve been working on an addon/script to export motion data from Blender to other programs, but I’ve run into a bit of a problem.

Without making this too long, what would be the best way to get the channel_matrix data of a pose from keyframe data? Unlike pose data(where you have access to several different matrices on the bone) keyframe data does not appear to be associated with any kind of absolute data relative to the world. Should I just rotate the data in all keyframes by the inverse of the bone’s matrix_local? Skipping to each keyframe’s frame, updating, and getting the bone’s matrix_channel is clearly not going to work… my only solution at present is to create a duplicate rig, reset its pose, and then copy the keyframe data>read the resulting matrix channel.