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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#!/usr/bin/env python
import subprocess
import time
import threading
import os
def kill_child(pid):
process_list = subprocess.check_output(['ps', 'a', '-o', 'ppid,pid'])
for line in process_list.split('\n'):
pids = line.split()
if len(pids) > 0:
if pids[0] == str(pid):
#print "Killing", pids[1]
os.kill(int(pids[1]), 9)
class ExecThread(threading.Thread):
def __init__(self, commands):
threading.Thread.__init__(self)
self.commands = commands
self.stopthread = threading.Event()
def run(self):
self.proc = subprocess.Popen(self.commands, stdout=open('/dev/null'))
#print "Starting", self.proc.pid
def stop(self):
kill_child(self.proc.pid)
pipelines = ['gst-launch v4l2src ! xvimagesink',
'gst-launch v4l2src ! tee name=tv ! queue ! xvimagesink sync=false tv. !'
+ ' theoraenc ! queue ! oggmux ! filesink location=/tmp/test.ogg',
'gst-launch v4l2src ! tee name=tv ! queue ! xvimagesink sync=false tv. !'
+ ' theoraenc ! queue ! oggmux ! filesink location=/dev/null',
'gst-launch v4l2src ! videoscale ! video/x-raw-yuv,width=160,height=120 !'
+ ' tee name=tv ! queue ! xvimagesink sync=false tv. ! theoraenc ! queue !'
+ ' oggmux ! filesink location=/dev/null',
'gst-launch v4l2src ! videoscale ! video/x-raw-yuv,width=320,height=240 !'
+ ' tee name=tv ! queue ! xvimagesink sync=false tv. ! theoraenc ! queue !'
+ ' oggmux ! filesink location=/dev/null',
'gst-launch v4l2src ! videoscale ! video/x-raw-yuv,width=400,height=300 !'
+ ' tee name=tv ! queue ! xvimagesink sync=false tv. ! theoraenc ! queue !'
+ ' oggmux ! filesink location=/dev/null',
'gst-launch v4l2src ! videoscale ! video/x-raw-yuv,width=400,height=300 !'
+ ' tee name=tv ! queue ! xvimagesink sync=false tv. ! vp8enc speed=2 ! '
+ ' queue ! oggmux ! filesink location=/dev/null']
for pipeline in pipelines:
commands = ['time']
commands.extend(pipeline.split())
print pipeline
th = ExecThread(commands)
th.run()
time.sleep(30)
th.stop()
time.sleep(1)
print
|