Skip to content

Commit 32c726d

Browse files
committed
automatic file paths
1 parent 7a7847b commit 32c726d

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Channels are supplied in the [configuration file](config.json) with a name and t
5656
``` curl http://sometvstation/master.m3u8 ```
5757

5858
* switching channels takes a couple of seconds
59+
* preview player is not killed automatically. [Possible solution](https://stackoverflow.com/questions/4789837/how-to-terminate-a-python-subprocess-launched-with-shell-true)
5960

6061
## License notes
6162

main.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@
44
from time import sleep
55
import json
66
from flask import Flask, render_template, request
7-
from playback import *
7+
from playback import *
8+
import os
89

910
app = Flask(__name__)
1011
vlc_process = None
1112

13+
configpath = os.path.dirname(os.path.abspath(__file__)) + "/config.json"
14+
1215
def get_stream_url(channel):
13-
with open("config.json") as urls_file:
16+
with open(configpath) as urls_file:
1417
urls_json = json.load(urls_file)
1518
return urls_json[channel]
1619

1720
def get_stream_list():
18-
with open("config.json") as urls_file:
21+
with open(configpath) as urls_file:
1922
urls_json = json.load(urls_file)
2023
result = list(urls_json.keys())
2124
print(result)
@@ -55,6 +58,7 @@ def preview():
5558
output_size = (1920,1080)
5659
command = mosaic(inputs,output_size,texts)
5760
vlc_process = subprocess.Popen(command, shell=True)
61+
print(vlc_process)
5862

5963
return render_template("channel_selector.html", channels = get_stream_list())
6064

playback.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/python3
22
import math
3+
import os
34

45
def mosaic(inputs, output_size, texts=None):
56
command = "ffmpeg "
@@ -10,7 +11,9 @@ def mosaic(inputs, output_size, texts=None):
1011
command += "%dx%d" % output_size # total size of output video
1112
command += "[tmp0];" # base target
1213

13-
font = "fontfile=./Inconsolata-Bold.ttf" # get font. Shipped with repo for convenience
14+
path = os.path.dirname(os.path.abspath(__file__))
15+
path += "/Inconsolata-Bold.ttf"
16+
font = "fontfile=%s" % path # get font. Shipped with repo for convenience
1417
part_size = (int(output_size[0] / math.ceil(len(inputs) / 2)),
1518
int(output_size[1] / math.floor(len(inputs) / 2))) # size for each subvideo
1619

@@ -53,5 +56,4 @@ def mosaic(inputs, output_size, texts=None):
5356
texts = ["ard-alpha","tagesschau24","3sat","arte"]
5457
output_size = (640,480)
5558
command = mosaic(inputs,output_size,texts)
56-
import os
5759
os.system(command)

0 commit comments

Comments
 (0)