I am new to python and ffmpeg. I have a following question to ask.
If I run the following command from command-line and it works.
ffmpeg -i 1.flv temp_filename
If I put it in a program
temp_file_handle, temp_filename = tempfile.mkstemp('.flv')
command = "ffmpeg -i " + newvideo.location + " "+ temp_filename
out = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
res = out.communicate()
The generated video didn’t write to the tem_filename. Why?
mkstempcreates the file itself, not just the file name. So the file will already exist whenffmpegattempts to write to it. Therefore it will ask whether you want to overwrite the file, or produce an error message, unless theffmpeg -yoption is used.