FIXED!!! How can I run an ffmpeg command in spyder which converts movies located on an external harddrive?

35 Views Asked by At

Error was something completely else. ffmpeg works just fine when giving the complete paths, the problem was a folder called freek data instead of freek_data rookie mistake :O

This is the command I use:

ffmpeg -i input.avi -vcodec msmpeg4v2 -acodec copy output.avi

It works, I've tested it. That is, it works when accessing a file on the local harddrive 'C:'. However, now my file is on an external harddrive: 'D:'. In a command terminal, the ffmpeg line still works by subsequently typing:

D:
ffmpeg -i input.avi -vcodec msmpeg4v2 -acodec copy output.avi

However, the module os.system which I use in spyder can't do that. How I use os.system:

command = f'ffmpeg -i {input} -vcodec msmpeg4v2 -acodec copy {input[:-4]}_com.avi'
os.system('D:') #if file on D:, otherwise leave this line out
os.system(command)

The os.system however doesn't seem to be able to run subsequent commands (probably an other term for this, but you may understand what I mean). Can someone give me a fix for how I can acces files on an external harddrive using ffmpeg in a spyder script?

Thannks in advance, Freek

What I tried: I tried using os.system and running two command after each other as explained in the desrciption. I looked online into the module subprocess, which I believe has some more functionalities compared to os.system, I however couldn't understand how it works and also don't know if it is capable of solving the problem at hand.

0

There are 0 best solutions below