And another related question: how to access a file via network from within a python script; the Network is a samba share.
I tried different things, but can't figure it out. I keep getting: No such file or directory
I am running the script like this:
$ /usr/bin/python3 "/home/nathaniel/Documents/my first python script.py"
This is my mount:
/media/nathaniel/ssd/
This is my file:
/media/nathaniel/ssd/test/SD/1.avi
I have been trying different things, but nothing works.
This is a simplified version of my script:
#!/usr/bin/env python
import subprocess
import tempfile
sourcedir = "/media/nathaniel/ssd/test/SD"
diroutput = "/media/nathaniel/ssd/test/HD"
sourceExt = "avi"
def getFileNames():
global filenamefirst
filenamefirst = int(input("enter file name NUMBER to start with: "))
global filenamelast
filenamelast = int(input("enter NUMBER of last file to process: "))
def main():
import os
import os.path
getFileNames()
for x in range(filenamefirst, filenamelast+1):
if os.path.exists(diroutput + "/" + str(x) + ".mp4"):
os.remove(diroutput + "/" + str(x) + ".mp4")
from subprocess import check_output
check_output("ffmpeg -i \"" + sourcedir + "/" + str(x) + "." + sourceExt + "\" -c:v libx264 -b:v 18M -c:a aac \"" + diroutput + "/" + str(x) + ".mp4\"")
print("^======= finished file " + str(x) + "." + sourceExt)
print("end")
main()
the error:
FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg -i "/media/nathaniel/ssd/test/SD/1.avi" -c:v libx264 -b:v 50M -c:a aac "/media/nathaniel/ssd/test/HD/1.mp4"': 'ffmpeg -i "/media/nathaniel/ssd/test/SD/1.avi" -c:v libx264 -b:v 50M -c:a aac "/media/nathaniel/ssd/test/HD/1.mp4"'
I found that any of these worked over a network:
"\\\\192.168.1.1\\c\\my.file"
"\\\\computername\\c\\my.file"
or locally:
"d:\\foldername\\my.file"