I have a little problem, I have trying for a lot time converted a video with FFMPEG in python 3 like this:
The model,
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)
And the code of converted.
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))
The error is this.
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
And also I have tried this:
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()
In this case the error is:
FileNotFoundError: [WinError 2] No such file or directory
But when I copy the path and paste this in CMD on windows for try this converted the video. It works fine.
Then, I am confused, I don't understand what is the error.
Somebody can help me please?
The file not found is file "ffmpeg". Try to enter file with path and extension : c:\Program Files\ffmpeg\ffmpeg.exe
Best Regard Emmanuel
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With