How run subprocess in Python 3 on windows for convert video?
<p>I have a little problem, I have trying for a lot time converted a video with FFMPEG in python 3 like this:</p>

<p>The model,</p>

<pre><code>class Video(models.Model):
   name = models.CharField(max_length=200, null=False)
   state = models.CharField(max_length=30, null=False)
   user_email = models.CharField(max_length=30, null=False)
   uploadDate = models.DateTimeField(null=False)
   message = models.CharField(max_length=200, null=False)
   original_video = models.FileField(upload_to='video', null=True)
   converted = models.BooleanField(default=False)
</code></pre>

<p>And the code of converted.</p>

<pre><code>video = Video.objects.filter(id=param_id).get()
pathConverted = 'C:\\Users\\diego\\Documents\\GitHub\\convertido.mp4'
cmd = ['ffmpeg', '-i ', video.original_video.path, ' -b 1500k -vcodec ibx264 -g 30', pathConverted]
print('Ejecutando... ', ' '.join(cmd))
try:
    proc = subprocess.run(cmd, shell=True, check=True)
    proc.subprocess.wait()
except subprocess.CalledProcessError as e:
    raise RuntimeError("command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))
</code></pre>

<p>The error is this.</p>

<pre><code> raise RuntimeError("command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output)) RuntimeError: command '['ffmpeg', '-i ', 'C:\\Users\\diego\\Documents\\GitHub\\video1.avi', ' -b 1500k -vcodec libx264 -g 30', 'C:\\Users\\diego\\Documents\\GitHub\\convertido.mp4']' return with error (code 1): None
</code></pre>

<p>And also I have tried this:</p>

<pre><code>video = Video.objects.filter(id=1).get()
pathConverted = 'C:\\Users\\diego\\Documents\\GitHub\\convertido.mp4'
cmd = ['ffmpeg', '-i ', video.original_video.path, ' -b 1500k -vcodec libx264 -g 30', pathConverted]
print('Ejecutando... ', ' '.join(cmd))
proc = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
proc.subprocess.wait()
</code></pre>

<p>In this case the error is:</p>

<pre><code>FileNotFoundError: [WinError 2] No such file or directory
</code></pre>

<p>But when I copy the path and paste this in CMD on windows for try this converted the video. It works fine.</p>

<p>Then, I am confused, I don't understand what is the error.</p>

<p>Somebody can help me please?</p>

<p>The file not found is file "ffmpeg".
Try to enter file with path and extension : c:\Program Files\ffmpeg\ffmpeg.exe</p>

<p>Best Regard
Emmanuel</p>

python django python-3.x cmd ffmpeg