Skip to content

Commit dcd8fe5

Browse files
committed
Metadata, and per video temp folders
1 parent 21b7d18 commit dcd8fe5

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

app.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,25 @@ def api_build():
8484

8585
with open("talks.json") as url:
8686
data = json.load(url)
87+
88+
description = None
8789
for talk in data:
8890
if talk["id"] == int(flask.request.form['talkid']):
8991
filename = "{}_{}".format(flask.request.form['talkid'], talk["slug"])
92+
description = talk["description"]
9093
break
9194
else:
9295
filename = "{}".format(flask.request.form['talkid'])
9396

9497
talk_data = {
9598
"title": flask.request.form['title'],
9699
"presenter": flask.request.form['presenter'],
97-
"filename": filename
100+
"filename": filename,
98101
}
102+
103+
if description:
104+
talk_data["description"] = description
105+
99106
vid_dir = str(pathlib.Path(flask.request.form['video']).parts[0])
100107
for source in app.config["VIDEO_SOURCES"]:
101108
if source["WEBDIR"] == vid_dir:

formvideo.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ def form_video(video, talk, start_tc, end_tc, framerate = FRAMERATE, out_dir = O
7373
spons_file = "resources/sponsor_slide_rounded.png"
7474

7575
# Generated files paths
76-
copr_file = "temp/copyright.png"
77-
spres_file = "temp/start_pres.png"
78-
stalk_file = "temp/start_title.png"
76+
copr_file = "copyright.png"
77+
spres_file = "start_pres.png"
78+
stalk_file = "start_title.png"
7979

8080
# Convert start and end to some other forms
8181
start_s = timecode_to_seconds(start_tc)
@@ -99,6 +99,12 @@ def form_video(video, talk, start_tc, end_tc, framerate = FRAMERATE, out_dir = O
9999
except KeyError:
100100
filename = start_timestamp
101101

102+
Path.joinpath(Path(temp_dir), Path(filename)).mkdir(parents=True, exist_ok=True)
103+
104+
copr_file = Path.joinpath(Path(temp_dir), Path(filename), copr_file)
105+
spres_file = Path.joinpath(Path(temp_dir), Path(filename), spres_file)
106+
stalk_file = Path.joinpath(Path(temp_dir), Path(filename), stalk_file)
107+
102108
output_file = Path(filename + ".mp4")
103109
log_file = Path(filename + ".log")
104110
output_path = Path.joinpath(Path(out_dir), output_file)
@@ -158,6 +164,18 @@ def form_video(video, talk, start_tc, end_tc, framerate = FRAMERATE, out_dir = O
158164
json_string += line
159165
loud_vals = json.loads(json_string)
160166

167+
# Build file metadata list
168+
metadata = [
169+
"-metadata", "title={}".format(talk["title"]),
170+
"-metadata", "artist={}".format(talk["presenter"]),
171+
"-metadata", "year=2024",
172+
]
173+
174+
try:
175+
metadata.extend(("-metadata", "synopsis={}".format(talk["description"])))
176+
except KeyError:
177+
pass
178+
161179
# Run the final build FFmpeg
162180
ffmpeg_args = [
163181
FFMPEG_BIN,
@@ -193,6 +211,7 @@ def form_video(video, talk, start_tc, end_tc, framerate = FRAMERATE, out_dir = O
193211

194212
),
195213
"-map", "[p1]", "-map", "[a1]", "-map_metadata", "-1",
214+
*metadata,
196215
"-c:v", "h264", "-crf", "16", "-g", str(math.floor(framerate/2)), "-flags", "+cgop",
197216
"-c:a", "aac", "-ar", "48000", "-b:a", "128k",
198217
"-r", str(framerate), "-pix_fmt", "yuv420p", "-movflags", "+faststart", output_path, "-y"

0 commit comments

Comments
 (0)