improve code for ffencoder video recording function.