-
Notifications
You must be signed in to change notification settings - Fork 0
/
ffmpeg_wrap.nim
41 lines (36 loc) · 1.07 KB
/
ffmpeg_wrap.nim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import os
import wnim
import winim
import nimpy
import strutils
var running_process = false
var the_proc: PyObject
var setme = false
let subprocess = pyImport("subprocess")
let py = pyBuiltinsModule()
let pipe = subprocess.PIPE
let app = App()
let frame = Frame(title="ffmpeg_wrap", size=(400, 300))
frame.connect(WM_MOVE) do (event: wEvent):
if running_process == false:
running_process = true
var command_str: string = paramStr(1)
for i in 2..paramCount():
var param: string = paramStr(i)
if("Game" in param and setme == false):
param = """video="Game Capture HD60 S":audio="Game Capture HD60 S Audio""""
setme = true
elif("Audio" in param):
param = ""
else:
param = paramStr(i)
command_str = command_str & " " & param
the_proc = subprocess.Popen(command_str, stdin=pipe)
frame.connect(WM_CLOSE) do (event: wEvent):
let pycommand = py.str.encode(py.str("q"), "utf-8")
discard the_proc.communicate(input=pycommand)
sleep(1000)
discard the_proc.terminate()
quit(0)
frame.center()
app.mainLoop()