0

I try to exectute : ./ffmpeg.exe -i "video.mkv" -vf subtitles="video.mkv" "video.mp4" This command works fine

But not in my python code


from pathlib import Path
import subprocess
import os


ffmpeg = r"D:\Archives\ffmpeg.exe"
os.chdir(r"D:\temp\video")
videos = Path(".")

for file_mkv in videos.glob("*.mkv"):
    file_mp4 = file_mkv.with_suffix(".mp4")
    subprocess.run([ffmpeg, "-i", file_mkv, "-vf", f'subtitles="{file_mkv}"', file_mp4])

Error : [Parsed_subtitles_0 @ 0000020cb26222c0] Unable to open "video.mkv" [AVFilterGraph @ 0000020cb715a380] Error initializing filter 'subtitles' with args '"video.mkv"' Error reinitializing filters! Failed to inject frame into filter network: Invalid argument Error while processing the decoded data for stream #0:0 Conversion failed!

user103162
  • 36
  • 4
  • 1
    Does this answer your question? [How to use ffmpeg in a python function](https://stackoverflow.com/questions/52197883/how-to-use-ffmpeg-in-a-python-function) – TDG Sep 03 '22 at 08:59

1 Answers1

1

change f'subtitles="{file_mkv}" to f"subtitles={file_mkv}" and it's works

subprocess.run([ffmpeg, "-i", file_mkv, "-vf", f"subtitles={file_mkv}", file_mp4])
user103162
  • 36
  • 4