Object appears transparent in render but not in viewport
When you use the tracking feature, blender sets the compositor up using three layers:

One Layer is the movie, on layer is the objects you want to add, and one layer is the shadow/ao layer to project the shadow and ambient occlusion from the object to the background(movie). 

As I can see from your nodesetup, the cubes are only visible on the background layer, but not on the foreground layer. Meaning you see the shadows and ambient occlusion but not the object iteself. Thus you have to


either adjust the visible layers in the render layer setup
or move the cubes to a layer that is rendered to foreground (probably the first layer, the second layer usually includes a plane to cast the shadow on)