Video stitching for static scene (infinite loop video)
Lets assume your camera axis has polar and azimuthal angles and you want to align your frames only regarding the azimuthal angle and set the polar angle free.

First you have to find the geometric transform between sequential frames of your video, then by multiplying these sequential geometric transforms between your reference frame and the current frame you could obtain the geometric transform between your current frame and the reference frame. To obtain geometric transform between sequential frames you could use automatic point matching algorithms like SIFT or SURF (considering all your frames don't have any intersections but sequential frames have intersection I suggested to use it sequentially).

After finding the geometric transform you have to modify the geometric transform to set the polar direction of camera free. To do this You have to decompose the geometric transform to find external camera parameters which contain the position and the pose of camera. Pose of camera is a Rotation matrix which rotate the axis of camera between your reference and current frame. After obtaining rotation matrix you have to decompose the rotation matrix to obtain the rotation angles which are yaw, pitch and roll and set Yaw angle to zero (I'm not sure which one is the polar angle of your camera but any of these angles which is polar angle of camera must be zero to set the polar direction free), then you have to obtain the modified geometric transform from the modified rotation matrix.

Now you could align all your frames using the inverse geometric transform.

All parts of suggested method have intrinsic MATLAB functions, also if your camera has nonlinear distortion like fish-eye you have to take care of that before point matching part.