Running a Unity Built from a Python Script

I have a video game and added to it “ffmpeg” to record the game for a few seconds. I developed the game in the editor mode and it works and records the videos. After that, I built the game and I was able to generate the Unity executable. When I tried to call the executable from a Python script, it started the game but did not do the recording.
However, when I do “build and run” it builds and runs the game successfully and also generates the video. Can anyone give me a hint on what I am doing wrong? Again the script is able to start the game but fails to do the recording.

Below is my Python script:

import subprocess

Unity_exe_path = r"D:\Python_CODE_UNITY\UnityExe\Unity.exe"

Unity_recording_path = r"D:\Python_CODE_UNITY\UnityExe\ Unity_Data\StreamingAssets\FFmpegOut\Windows\ffmpeg.exe"

subprocess.Popen(Unity_exe_path)

subprocess.Popen(Unity_recording_path)

What python is this? Last I checked the default Unity package for python is editor-only, but looking now I don’t see that explicitly in the docs.

Thank you for your response.

To clarify, I developed and tested the game in the Unity Editor, including the integration with ffmpeg for recording, and it works as expected. However, after building the game into a standalone executable, the video recording does not start when running the executable through a Python script.

Additionally, when I build my Unity scenes and run Unity.exe, it does not record the scenes. However, when I use “Build and Run,” it records the scene, but after closing and re-running it, it does not record.