Aman Agrawal
Aman Agrawal

Reputation: 193

Subprocess.call ffmpeg making empty file

I am trying to convert video from one format to other.

extension = '.avi'
extension_less_url = '../uploads/video'
import subprocess
subprocess.call(['ffmpeg', '-i', extension_less_url + extension, extension_less_url + '.mp4'])

But above produces an empty file named 'video.mp4'. How to correct? This is the error I am getting:

The encoder 'aac' is experimental but experimental codecs are not enabled, add '-strict -2' if you want to use it.

Upvotes: 1

Views: 493

Answers (2)

M. D. P
M. D. P

Reputation: 764

import subprocess

subprocess.call('ffmpeg -f vfwcap -t 10 -r 25 -i 0 c:/test/sample11.avi')

python have a subprocess module which helps for running exec command.

In case if you want to run multiple cmd or shell commands one after another you can use the following :

subprocess.check_call("cd /home/pi/images; ls", shell=True)

here : "cd /home/pi/images" is one command which is separated using ";" to run another command "ls"

Upvotes: 1

Ahmadreza Pourghodrat
Ahmadreza Pourghodrat

Reputation: 98

This problem is for '.mp4'. try something else like '.mkv' for the target format of your video. I've done this and the problem is solved

Upvotes: 2

Related Questions