-
Notifications
You must be signed in to change notification settings - Fork 1
/
cameraman
executable file
·182 lines (157 loc) · 5.11 KB
/
cameraman
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/usr/bin/python
#
# cameraman: Dicky B ([email protected])
#
# this is what sends the feed of the main video file to ffserver.
# It kills any channel instance of director and fillshow, then
# does the business with the desired video file, resuming if
# necessary.
#
# when the main video is over, or aborts, dofiller is run.
#
import os
import datetime
import sys
import random
#
#get basepath
basepath=os.path.dirname(os.path.realpath(__file__))+'/'
if len(sys.argv)!= 4:
print "Usage: cameraman <channel> <video> <offset in seconds>"
exit()
#write pid to channel's director.pid for killing later.
pid=os.getpid()
f=open(channelPath+'cameraman.pid','w')
f.write(str(pid))
f.write('\n')
f.close()
#this entire hunk sets up the config.
#there is cruft in this bit. Left it Just In Case for now.
channelpath=""
ffmpeg = ""
ffmpegpath = ""
logoimage=""
feedurl = ""
dyntext1=""
dyntext2=""
dyntext3=""
dynfont1 = ""
dynfont2 = ""
dynfont3 = ""
inphone = ""
inphonefont = ""
splashpath=""
splashname=""
splashext=""
name = sys.argv[1]
channelName=name
channelPath=basepath+channelName+'/'
f = open(channelPath+'channel.conf')
lines=f.readlines()
f.close()
for b in lines:
c=b.strip()
line=c.split('=')
if line[0].strip() == 'ffmpeg':
ffmpegname=line[1].strip()
if line[0].strip() == 'ffmpegpath':
ffmpegpath=line[1].strip()
if line[0].strip() == 'channelfullname':
channelFullName=line[1].strip()
if line[0].strip() == 'showspath':
showspath=line[1].strip()
if line[0].strip() == 'feedurl':
feedurl=line[1].strip()
if line[0].strip() == 'splashpath':
splashpath=line[1].strip()
if line[0].strip() == 'splashname':
splashname=line[1].strip()
if line[0].strip() == 'splashext':
splashext=line[1].strip()
if line[0].strip() == 'dyntext1':
dyntext1=line[1].strip()
if line[0].strip() == 'dynfont1':
dynfont1=line[1].strip()
if line[0].strip() == 'dyntext2':
dyntext2=line[1].strip()
if line[0].strip() == 'dynfont2':
dynfont2=line[1].strip()
if line[0].strip() == 'dyntext3':
dyntext3=line[1].strip()
if line[0].strip() == 'dynfont3':
dynfont3=line[1].strip()
if line[0].strip() == 'inphone':
inphone=line[1].strip()
if line[0].strip() == 'phonefont':
inphonefont=line[1].strip()
if line[0].strip() == 'logoimage':
logoimage=line[1].strip()
ffmpegcmd = ffmpegpath+ffmpegname
fontpath = basepath+'Font/'
logopath = basepath+'Logo/'+logoimage
#end config init
#get the offset from args
optoff="-ss "+sys.argv[3]
q=sys.argv[3]
offset = ""
offset = q
#lenfile = channelPath+"current.length"
#f=open(lenfile,'r')
#tmp=f.readlines()
#f.close()
#curlen=tmp[0].strip()
video= sys.argv[2]
# make sure all cruft is clean
os.system(basepath+'killcruft '+channelName)
# if it's the beginning of a show, clear the
# optional text and show
# a station ID splash video
if offset == '0':
os.system(basepath+"cleartext")
rando=str(random.randint(1,2))
whichsplash=splashpath+splashname+rando+splashext
os.system(basepath+'fshow '+channelName+' "'+whichsplash+'"')
# this next chunk sets up the commandline that will execute
# ffmpeg and send it to ffserver.
# be sure to use realtime switch
precom=ffmpegcmd+" -re "
zcom = " -i "
#this monster is the custom stuff for ffmpeg
#either work with it as-is, or redo it,
#pretty much the same as the monster in fillshow
#so remember to change it there, too.
#not putting this in stationlib because
#it's not any easier to work there than here and
#fillshow (which may be different anyway)
#this is a basic version without overlays.
postcom=' -c:v mpeg2video \
-b:v 6000k \
-c:a libfaac \
-b:a 128k \
-f mpegts - | '+ffmpegcmd+' -re -i - '+feedurl
#this supports some overlays, and is commented out for reference.
#postcom=' -i '+logopath+' -filter_complex \
#"[0:v]scale=-1:720,\
#drawtext=fontsize=22:[email protected]:[email protected]:fontfile='+fontpath+dynfont1+':textfile='+dyntext1+':reload=1:shadowx=1:shadowy=1:x=w-tw-5:y=5,\
#drawtext=fontsize=18:[email protected]:fontfile='+fontpath+dynfont2+':[email protected]:shadowx=1:shadowy=1:textfile='+dyntext2+':reload=1:x=3:y=5,\
#drawtext=fontsize=22:fontcolor=white@1:fontfile='+fontpath+dynfont3+':textfile='+dyntext3+':reload=1:box=1:[email protected]:x=(w/2)-(tw/2):y=h-(th*2),\
#drawtext=fontsize=32:fontcolor=white@1:fontfile='+fontpath+inphonefont+':textfile='+inphone+':reload=1:box=1:[email protected]:x=(w/2)-(tw/2):y=(h/2)-(th/2)[text]; \
#[text][1:v]overlay=main_w-120:main_h-120[filtered]" -map "[filtered]" \
#-map 0:a \
#-c:v mpeg2video \
#-b:v 6000k \
#-c:a libfaac \
#-b:a 128k \
#-f mpegts - | '+ffmpegcmd+' -re -i - '+feedurl
#
# assemble the monster. Unsure if the second realtime switch (-re) is necessary above,
# but it doesn't hurt to have it there, so have it there.
twocom = precom+optoff+zcom+'"'+video+'"'+postcom
#uncomment for live
os.system(twocom)
#comment for live
#print twocom
#
#when above is done, run a filler
#comment for not live
os.system(basepath+'dofiller "'+basepath+'" '+channelName)