Moved render_video function