1

I'm using subprocess.run() that uses an argument that references a file as "./0.mkv"

It tells me it cannot find the file "./0.mkv", do I need to reference the entire path or is there a way to make ./ refer correctly?

Or maybe it's something else entirely, I'm not sure.

This is the actual code:

temp_file_path = "./0.mkv"
final_file_path = "./0hardsubs.mkv"

cmd = ['ffmpeg', '-i', f'"{temp_file_path}"', \
       '-filter_complex', f'"subtitles=\'{temp_file_path}\'"', \
       f'"{final_file_path}"', '-y', '-loglevel', 'warning', '-stats']

subprocess.run(cmd)

This is the output:

"./0.mkv": No such file or directory
Baa
  • 438
  • 3
  • 7
  • 22

1 Answers1

0

Turns out this was something else. I tried print(os.path.getsize(temp_file_path)) and recieved the correct output so Python was clearly able to see the file.

Once I removed the double quotes around the ffmpeg input, filter and output everything worked fine. Not sure how that's possible but I guess that's a feature of subprocess.run that it sanitises the arguments automatically?

For anyone interested, here's the final output:

temp_file_path = "./0.mkv"
final_file_path = "./0hardsubs.mkv"

cmd = ['ffmpeg', '-i', f'{temp_file_path}', \
       '-filter_complex', f'subtitles=\'{temp_file_path}\'', \
       f'{final_file_path}', '-y', '-loglevel', 'warning', '-stats']

subprocess.run(cmd)
Baa
  • 438
  • 3
  • 7
  • 22