final video generation code