Mar-19-2025, 07:50 PM
(This post was last modified: Mar-19-2025, 07:50 PM by rjdegraff42.)
I'm trying to run ffplay (ffmpeg utility) as an external process. It works fine until I add arguments to include a subtitle file. The command to do this from a cmd shell is (as an example) without and with subtitles
ffplay D:\temp\myvideo.mp4 -volume 20 -left 50 -top 150
ffplay D:\temp\myvideo.mp4 -volume 20 -left 50 -top 150 -vf subtitles="D\\\:\\\\temp\\\\myvideo.srt"
Note that for some unknown reason the programmers decided on a different filespec format for the filter. Accounting for this is not a huge problem, however, when I try to run this by
process = subprocess.Popen(command, stderr=subprocess.PIPE, text=True, bufsize=1)
I get
D:\apps\Subtitle>showtime D:\temp\myvideo.mp4
ffplay D:\temp\myvideo.mp4 -volume 20 -left 50 -top 150 -vf subtitles="D\\\:\\\\temp\\\\myvideo.srt"
['ffplay',
'D:\\temp\\myvideo.mp4',
'-volume',
'20',
'-left',
'50',
'-top',
'150',
'-vf',
'subtitles="D\\\\\\:\\\\\\\\temp\\\\\\\\myvideo.srt"']
ffplay exited with return code: 0
When I copy the composed command and paste it into a cmd shell it runs as expected. It's only when spawning it from withoon Python that I get the error. When run my script against a video it detects the presence or absense of an srt file and adjusts the command accordingly. If there is no srt file the script works just fine.
My Python version is Python 3.12.8 (tags/v3.12.8:2dc476b, Dec 3 2024, 19:30:04) [MSC v.1942 64 bit (AMD64)] on win32/Windows 11 Home
ffplay D:\temp\myvideo.mp4 -volume 20 -left 50 -top 150
ffplay D:\temp\myvideo.mp4 -volume 20 -left 50 -top 150 -vf subtitles="D\\\:\\\\temp\\\\myvideo.srt"
Note that for some unknown reason the programmers decided on a different filespec format for the filter. Accounting for this is not a huge problem, however, when I try to run this by
process = subprocess.Popen(command, stderr=subprocess.PIPE, text=True, bufsize=1)
I get
D:\apps\Subtitle>showtime D:\temp\myvideo.mp4
ffplay D:\temp\myvideo.mp4 -volume 20 -left 50 -top 150 -vf subtitles="D\\\:\\\\temp\\\\myvideo.srt"
['ffplay',
'D:\\temp\\myvideo.mp4',
'-volume',
'20',
'-left',
'50',
'-top',
'150',
'-vf',
'subtitles="D\\\\\\:\\\\\\\\temp\\\\\\\\myvideo.srt"']
ffplay exited with return code: 0
When I copy the composed command and paste it into a cmd shell it runs as expected. It's only when spawning it from withoon Python that I get the error. When run my script against a video it detects the presence or absense of an srt file and adjusts the command accordingly. If there is no srt file the script works just fine.
My Python version is Python 3.12.8 (tags/v3.12.8:2dc476b, Dec 3 2024, 19:30:04) [MSC v.1942 64 bit (AMD64)] on win32/Windows 11 Home