Python Forum
Problem running external process
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem running external process
#1
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  problem in running a code akbarza 7 2,203 Feb-14-2024, 02:57 PM
Last Post: snippsat
  Controlling what get outputted to stdout when running external commands Daring_T 4 3,539 Jan-30-2022, 05:40 PM
Last Post: bowlofred
  rtmidi problem after running the code x times philipbergwerf 1 3,047 Apr-04-2021, 07:07 PM
Last Post: philipbergwerf
  python to exe running problem Roshan 2 6,890 Mar-30-2021, 08:59 AM
Last Post: Roshan
  Get stdout of a running process yok0 0 4,329 Aug-20-2020, 10:12 AM
Last Post: yok0
  Problem running script within console koepjo 3 10,975 Mar-26-2020, 07:11 AM
Last Post: koepjo
  Running problem cristipatras 4 3,462 Feb-20-2020, 12:03 PM
Last Post: jefsummers
  problem running python file using cmd panzers 2 3,081 Dec-19-2019, 04:04 PM
Last Post: panzers
  How to sharing object between multiple process from main process using Pipe Subrata 1 4,423 Sep-03-2019, 09:49 PM
Last Post: woooee
  Problem: Once I cancel the process my program will start working! Hadad 0 2,012 Jul-24-2019, 04:09 PM
Last Post: Hadad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020