if not re.match('.*matroska,webm,.*', infos, re.DOTALL): if re.match('.*, gif, from.*', infos, re.DOTALL): pipe = subprocess.Popen([ffmpeg_bin, '-y', # force overwrite '-i', chunked_file.file.name, '-f', 'webm', '-c:v', 'libvpx', '-crf', '12', '-b:v', '500K', chunked_file.file.name], # output to original file stdout=subprocess.PIPE, stderr=subprocess.PIPE) pipe.wait() pipe = subprocess.Popen([ffmpeg_bin, '-i', chunked_file.file.name], stdout=subprocess.PIPE, stderr=subprocess.PIPE) pipe.stdout.readline() infos = pipe.stderr.read() else: return AjaxResponseError({'error': 'wrongformat'})