0

I am creating a python script that will convert files using ffmpeg and unoconv. However when I run the program, rather than getting a converted file the program simply displays the text:

sh: 1: unoconv -f: not found

Here is the script for my program:

    path = raw_input("Please drag and drop the directory in which the file is stored into the terminal:")
    os.chdir(path[1:-2])
    filename = raw_input("Please enter the name of the file you would like to convert, including the file-type. e.g. test.txt, however please do make sure that the file-name does not have any spaces:")
    Fileextension = raw_input("What filetype would you like the program to convert your file to. E.g. .mp3: ")
    body, ext = os.path.splitext("filename")
    os.system("'ffmpeg -i ' + filename + body + Fileextension ")

Any ideas as to why this happens?

2 Answers 2

2

Look at your command:

os.system("'ffmpeg -i ' + filename + body + Fileextension ")

You try to executed this literal string.

Try:

os.system('ffmpeg -i ' + filename + body + Fileextension)

Also, it is recommended to use subprocess instead of os.system.

Sign up to request clarification or add additional context in comments.

3 Comments

@kindall Should be just a file name: usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
@Mike Müller I tried this soluton, but when I did it i got no result. I only got the error code : :unoconv: you have to provide a filename as argument Try unoconv -h' for more information.` Do you have any idea as to how I can fix this.
Run it at the command line first. Make sure it works. Then print the command before executing it.
1

You should use the subprocess module, in particular subprocess.check_call passing a list of args:

from subprocess import check_call
check_call(["ffmpeg" ,"-i",filename + body + Fileextension])

Any non-zero exit code will raise a CalledProcessError

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.