video writing code