Advertisement
sleem4k

vlc.artur

Sep 12th, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.75 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # Created by ZeFs, 28.07.2011
  4. # for S.E. "Radiocomunicatii"
  5. ### BEGIN INIT INFO
  6. # Provides: vlc transcoder
  7. # Required-Start: $local_fs $remote_fs $network $syslog $named
  8. # Required-Stop: $local_fs $remote_fs $network $syslog $named
  9. # Default-Start: 2 3 4 5
  10. # Default-Stop: 0 1 6
  11. # X-Interactive: true
  12. # Short-Description: Start/stop vlc transcode server
  13. ### END INIT INFO
  14.  
  15. # VLC configuration
  16. LOG_DIR="/opt/dvb-t/vlc/log"
  17. PID_DIR="/opt/dvb-t/vlc/pids"
  18.  
  19. LOG_FILE1="$LOG_DIR/program1.log"
  20. LOG_FILE2="$LOG_DIR/program2.log"
  21. LOG_FILE3="$LOG_DIR/program3.log"
  22. LOG_FILE4="$LOG_DIR/program4.log"
  23. LOG_FILE5="$LOG_DIR/program5.log"
  24. LOG_FILE6="$LOG_DIR/program6.log"
  25. LOG_FILE7="$LOG_DIR/program7.log"
  26. LOG_FILE8="$LOG_DIR/program8.log"
  27. LOG_FILE9="$LOG_DIR/program9.log"
  28. LOG_FILE10="$LOG_DIR/program10.log"
  29. PID_FILE1="$PID_DIR/pidfile_p1.pid"
  30. PID_FILE2="$PID_DIR/pidfile_p2.pid"
  31. PID_FILE3="$PID_DIR/pidfile_p3.pid"
  32. PID_FILE4="$PID_DIR/pidfile_p4.pid"
  33. PID_FILE5="$PID_DIR/pidfile_p5.pid"
  34. PID_FILE6="$PID_DIR/pidfile_p6.pid"
  35. PID_FILE7="$PID_DIR/pidfile_p7.pid"
  36. PID_FILE8="$PID_DIR/pidfile_p8.pid"
  37. PID_FILE9="$PID_DIR/pidfile_p9.pid"
  38. PID_FILE10="$PID_DIR/pidfile_p10.pid"
  39. PROGRAM1="rtp://239.0.12.1:5000"
  40. PROGRAM2="rtp://239.0.12.2:5000"
  41. PROGRAM3="rtp://239.0.12.3:5000"
  42. PROGRAM4="rtp://239.0.12.4:5000"
  43. PROGRAM5="rtp://239.0.15.1:5000"
  44. PROGRAM6="rtp://239.0.15.2:5000"
  45. PROGRAM7="rtp://239.0.15.3:5000"
  46. PROGRAM8="rtp://239.0.15.4:5000"
  47. PROGRAM9="rtp://239.0.18.1:5000"
  48. PROGRAM10="rtp://239.0.18.3:5000"
  49. LOGMODE="text"
  50. #venc="x264{profile=baseline,level=3.0,keyint=30,preset=veryfast,tune=film,vbv-bufsize=25000,vbv-maxrate=30000}"
  51. venc="x264{keyint=60,profile=baseline,level=3.0,nocabac,preset=veryfast,tune=film,vbv-bufsize=30000,vbv-maxrate=30000}"
  52. vcodec="x264"
  53. acodec="mp4a"
  54. bitrate="500"
  55. arate="96"
  56. fps="20"
  57. mux="ts"
  58. height="240"
  59. width="320"
  60. dst="10.0.254.170"
  61. VLC="/opt/dvb-t/vlc/bin/cvlc --file-logging --log-verbose 3 --logmode $LOGMODE --daemon --sout-transcode-high-priority"
  62. #quit vlc
  63. #vlc://quit
  64. #--config $config
  65.  
  66. START_PROGRAM1="$VLC $PROGRAM1 --logfile $LOG_FILE1 --pidfile $PID_FILE1 --sout "#transcode{venc=$venc,deinterlace,vcodec=$vcodec,vb=$bitrate,height=$height,fps=$fps,acodec=$acodec,ab=$arate,channels=1,samplerate=48000}:rtp{dst=$dst,port=1001,mux=$mux,sdp=rtsp://0.0.0.0:1001/program1.sdp,name="program1"}""
  67. START_PROGRAM2="$VLC $PROGRAM2 --logfile $LOG_FILE2 --pidfile $PID_FILE2 --sout "#transcode{venc=$venc,deinterlace,vcodec=$vcodec,vb=$bitrate,height=$height,fps=$fps,acodec=$acodec,ab=$arate,channels=1,samplerate=48000}:rtp{dst=$dst,port=1003,mux=$mux}""
  68. START_PROGRAM3="$VLC $PROGRAM3 --logfile $LOG_FILE3 --pidfile $PID_FILE3 --sout "#transcode{venc=$venc,deinterlace,vcodec=$vcodec,vb=$bitrate,height=$height,fps=$fps,acodec=mp3,ab=128,channels=2,samplerate=48000}:rtp{dst=$dst,port=1005,mux=$mux}""
  69. START_PROGRAM4="$VLC $PROGRAM4 --logfile $LOG_FILE4 --pidfile $PID_FILE4 --sout "#transcode{venc=$venc,deinterlace,vcodec=$vcodec,vb=$bitrate,height=$height,fps=$fps,acodec=$acodec,ab=$arate,channels=1,samplerate=48000}:rtp{dst=$dst,port=1007,mux=$mux}""
  70. START_PROGRAM5="$VLC $PROGRAM5 --logfile $LOG_FILE5 --pidfile $PID_FILE5 --sout "#transcode{venc=$venc,deinterlace,vcodec=$vcodec,vb=$bitrate,height=$height,fps=$fps,acodec=$acodec,ab=$arate,channels=1,samplerate=48000}:rtp{dst=$dst,port=1009,mux=$mux}""
  71. START_PROGRAM6="$VLC $PROGRAM6 --logfile $LOG_FILE6 --pidfile $PID_FILE6 --sout "#transcode{venc=$venc,deinterlace,vcodec=$vcodec,vb=$bitrate,height=$height,fps=$fps,acodec=$acodec,ab=$arate,channels=2,samplerate=48000}:rtp{dst=$dst,port=1011,mux=$mux}""
  72. START_PROGRAM7="$VLC $PROGRAM7 --logfile $LOG_FILE7 --pidfile $PID_FILE7 --sout "#transcode{venc=$venc,deinterlace,vcodec=$vcodec,vb=$bitrate,height=$height,fps=$fps,acodec=$acodec,ab=$arate,channels=2,samplerate=48000}:rtp{dst=$dst,port=1013,mux=$mux}""
  73. START_PROGRAM8="$VLC $PROGRAM8 --logfile $LOG_FILE8 --pidfile $PID_FILE8 --sout "#transcode{venc=$venc,deinterlace,vcodec=$vcodec,vb=$bitrate,height=$height,fps=$fps,acodec=$acodec,ab=$arate,channels=2,samplerate=48000}:rtp{dst=$dst,port=1015,mux=$mux}""
  74. START_PROGRAM9="$VLC $PROGRAM9 --logfile $LOG_FILE9 --pidfile $PID_FILE9 --sout "#transcode{venc=$venc,deinterlace,vcodec=$vcodec,vb=$bitrate,width=$width,fps=$fps,acodec=$acodec,ab=$arate,channels=2,samplerate=48000}:rtp{dst=$dst,port=1017,mux=$mux}""
  75. START_PROGRAM10="$VLC $PROGRAM10 --logfile $LOG_FILE10 --pidfile $PID_FILE10 --sout "#transcode{venc=$venc,deinterlace,vcodec=$vcodec,vb=$bitrate,height=$height,fps=$fps,acodec=$acodec,ab=$arate,channels=2,samplerate=48000}:rtp{dst=$dst,port=1019,mux=$mux}""
  76.  
  77. # ,vfilter=croppadd{paddtop=53,paddbottom=53}
  78. #START_CAM="$VLC -vvv $PROGRAM_CAM --mjpeg-fps=5 --sout-transcode-high-priority --no-sout-audio --sout "#transcode{venc=$venc,vcodec=$vcodec,vb=500,width=640,height=480}:rtp{dst=127.0.0.1,port=10000}""
  79.  
  80. start() {
  81.  
  82. echo "Starting transcoder $VLC"
  83.  
  84. $START_PROGRAM1
  85. $START_PROGRAM2
  86. $START_PROGRAM3
  87. $START_PROGRAM4
  88. $START_PROGRAM5
  89. $START_PROGRAM6
  90. $START_PROGRAM7
  91. $START_PROGRAM8
  92. $START_PROGRAM9
  93. $START_PROGRAM10
  94. # $START_CAM
  95. }
  96.  
  97. stop() {
  98. echo "Stopping transcoder $VLC"
  99.  
  100. kill -9 `cat $PID_FILE1`
  101. kill -9 `cat $PID_FILE2`
  102. kill -9 `cat $PID_FILE3`
  103. kill -9 `cat $PID_FILE4`
  104. kill -9 `cat $PID_FILE5`
  105. kill -9 `cat $PID_FILE6`
  106. kill -9 `cat $PID_FILE7`
  107. kill -9 `cat $PID_FILE8`
  108. kill -9 `cat $PID_FILE9`
  109. kill -9 `cat $PID_FILE10`
  110. rm $LOG_DIR/*
  111. # kill -9 `cat $PID_FILE_CAM`
  112. }
  113.  
  114. start_p1() {
  115.  
  116. echo "Start transcoding program 1[Moldova1]"
  117. $START_PROGRAM1
  118.  
  119. }
  120.  
  121. stop_p1() {
  122.  
  123. echo "Stop transcoding service 1[Moldova1]"
  124. kill -9 `cat $PID_FILE1`
  125. rm $LOG_FILE1
  126.  
  127. }
  128.  
  129. start_p2() {
  130.  
  131. echo "Start transcoding program 2[Prime]"
  132. $START_PROGRAM2
  133.  
  134. }
  135.  
  136. stop_p2() {
  137.  
  138. echo "Stop transcoding service 2[Prime]"
  139. kill -9 `cat $PID_FILE2`
  140. rm $LOG_FILE2
  141.  
  142. }
  143.  
  144. start_p3() {
  145.  
  146. echo "Start transcoding program 3[NIT]"
  147. $START_PROGRAM3
  148.  
  149. }
  150.  
  151. stop_p3() {
  152.  
  153. echo "Stop transcoding service 3[NIT]"
  154. kill -9 `cat $PID_FILE3`
  155. rm $LOG_FILE3
  156.  
  157. }
  158.  
  159. start_p4() {
  160.  
  161. echo "Start transcoding program 4[N4]"
  162. $START_PROGRAM4
  163.  
  164. }
  165.  
  166. stop_p4() {
  167.  
  168. echo "Stop transcoding service 4[N4]"
  169. kill -9 `cat $PID_FILE4`
  170. rm $LOG_FILE4
  171.  
  172. }
  173.  
  174. start_cam() {
  175. echo "Start transcoding CAM data"
  176. $START_CAM
  177. }
  178.  
  179. stop_cam(){
  180. echo "Stop transcoding CAM"
  181. kill -9 `cat $PID_FILE_CAM`
  182.  
  183. }
  184.  
  185. start_p5() {
  186.  
  187. echo "Start transcoding program 5[2PLUS]"
  188. $START_PROGRAM5
  189.  
  190. }
  191.  
  192. stop_p5() {
  193.  
  194. echo "Stop transcoding service 5[2PLUS]"
  195. kill -9 `cat $PID_FILE5`
  196. rm $LOG_FILE5
  197.  
  198. }
  199.  
  200. start_p6() {
  201.  
  202. echo "Start transcoding program 6[ALT-TV]"
  203. $START_PROGRAM6
  204.  
  205. }
  206.  
  207. stop_p6() {
  208.  
  209. echo "Stop transcoding service 6[ALT-TV]"
  210. kill -9 `cat $PID_FILE6`
  211. rm $LOG_FILE6
  212.  
  213. }
  214.  
  215. start_p7() {
  216.  
  217. echo "Start transcoding program 7[PUBLIKA-TV]"
  218. $START_PROGRAM7
  219.  
  220. }
  221.  
  222. stop_p7() {
  223.  
  224. echo "Stop transcoding service 7[PUBLIKA-TV]"
  225. kill -9 `cat $PID_FILE7`
  226. rm $LOG_FILE7
  227.  
  228. }
  229.  
  230. start_p8() {
  231.  
  232. echo "Start transcoding program 8[ACCENT TV]"
  233. $START_PROGRAM8
  234.  
  235. }
  236.  
  237. stop_p8() {
  238.  
  239. echo "Stop transcoding service 8[ACCENT TV]"
  240. kill -9 `cat $PID_FILE8`
  241. rm $LOG_FILE8
  242.  
  243. }
  244.  
  245. start_p9() {
  246.  
  247. echo "Start transcoding program 9[RU TV]"
  248. $START_PROGRAM9
  249.  
  250. }
  251.  
  252. stop_p9() {
  253.  
  254. echo "Stop transcoding service 9[RU TV]"
  255. kill -9 `cat $PID_FILE9`
  256. rm $LOG_FILE9
  257.  
  258. }
  259.  
  260. start_p10() {
  261.  
  262. echo "Start transcoding program 10[Scrambled TV]"
  263. $START_PROGRAM10
  264.  
  265. }
  266.  
  267. stop_p10() {
  268.  
  269. echo "Stop transcoding service 10[Scrambled TV]"
  270. kill -9 `cat $PID_FILE10`
  271. rm $LOG_FILE10
  272.  
  273. }
  274.  
  275. # See how we were called.
  276. case "$1" in
  277. start)
  278. start
  279. ;;
  280. stop)
  281. stop
  282. ;;
  283. restart|reload)
  284. stop
  285. sleep 1
  286. start
  287. ;;
  288. start_p1)
  289. start_p1
  290. ;;
  291. stop_p1)
  292. stop_p1
  293. ;;
  294. restart_p1)
  295. stop_p1
  296. sleep 1
  297. start_p1
  298. ;;
  299. start_p2)
  300. start_p2
  301. ;;
  302. stop_p2)
  303. stop_p2
  304. ;;
  305. restart_p2)
  306. stop_p2
  307. sleep 1
  308. start_p2
  309. ;;
  310. start_p3)
  311. start_p3
  312. ;;
  313. stop_p3)
  314. stop_p3
  315. ;;
  316. restart_p3)
  317. stop_p3
  318. sleep 1
  319. start_p3
  320. ;;
  321. start_p4)
  322. start_p4
  323. ;;
  324. stop_p4)
  325. stop_p4
  326. ;;
  327. restart_p4)
  328. stop_p4
  329. sleep 1
  330. start_p4
  331. ;;
  332. start_p5)
  333. start_p5
  334. ;;
  335. stop_p5)
  336. stop_p5
  337. ;;
  338. restart_p5)
  339. stop_p5
  340. sleep 1
  341. start_p5
  342. ;;
  343. start_p6)
  344. start_p6
  345. ;;
  346. stop_p6)
  347. stop_p6
  348. ;;
  349. restart_p6)
  350. stop_p6
  351. sleep 1
  352. start_p6
  353. ;;
  354. start_p7)
  355. start_p7
  356. ;;
  357. stop_p7)
  358. stop_p7
  359. ;;
  360. restart_p7)
  361. stop_p7
  362. sleep 1
  363. start_p7
  364. ;;
  365. start_p8)
  366. start_p8
  367. ;;
  368. stop_p8)
  369. stop_p8
  370. ;;
  371. restart_p8)
  372. stop_p8
  373. sleep 1
  374. start_p8
  375. ;;
  376. start_p9)
  377. start_p9
  378. ;;
  379. stop_p9)
  380. stop_p9
  381. ;;
  382. restart_p9)
  383. stop_p9
  384. sleep 1
  385. start_p9
  386. ;;
  387. start_p10)
  388. start_p10
  389. ;;
  390. stop_p10)
  391. stop_p10
  392. ;;
  393. restart_p10)
  394. stop_p10
  395. sleep 1
  396. start_p10
  397. ;;
  398. start_cam)
  399. start_cam
  400. ;;
  401. stop_cam)
  402. stop_cam
  403. ;;
  404. restart_cam)
  405. stop_cam
  406. sleep 1
  407. start_cam
  408. ;;
  409. *)
  410. echo "Usage: $0 {start|stop|restart|reload|start_p*|stop_p*|restart_p*}"
  411.  
  412. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement