.exe
suggests that you are on Windows where the native interface to specify a command to run is a string i.e., paste the string as is:
#!/usr/bin/env python
import subprocess
subprocess.check_call('ffmpeg.exe -f dshow -y -video_size 1920x1080 '
'-rtbufsize 1404000k -r 30 '
'-i video="HD Video 2 (TC-2000HDMI Card)" '
'-threads 2 -vcodec copy -ar 48000 -ac 1 -acodec pcm_s16le '
r'-t 60 c:\output.avi')
Note: the command is split into several literals only to spread it over multiple lines for readability. 'a' 'b'
literals coalesce into 'ab'
in Python.
If the command is not a literal string then it might be more convient to use a list, to specify the command:
#!/usr/bin/env python
import subprocess
nthreads = 2
width, height = 1920, 1080
filename = r'c:\output.avi'
subprocess.check_call([
'ffmpeg', '-f', 'dshow', '-y',
'-video_size', '%dx%d' % (width, height),
'-rtbufsize', '1404000k', '-r', '30',
'-i', 'video=HD Video 2 (TC-2000HDMI Card)',
'-threads', str(nthreads), '-vcodec', 'copy', '-ar', '48000', '-ac', '1',
'-acodec', 'pcm_s16le', '-t', '60',
filename])
Note: if only a name without a path and file extension is given then .exe
is appended automatically. This also makes the second form more portable.
To avoid escaping backslash in Windows paths, raw string literals could be used i.e., you could write r'C:\User\...'
instead of 'C:\\User\\...'
.