Modify the def write_before to write_video as write_video fails