Skip to content

Commit 6ec8241

Browse files
committed
Make ffmpeg log directory configurable through app config
1 parent 89ba1f1 commit 6ec8241

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

hackyplayer/app.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ def api_build():
108108
flask.request.form['start_tc'],
109109
flask.request.form['end_tc'],
110110
out_dir = str(app.config["VIDEO_OUTPUT"]),
111-
temp_dir = str(app.config["VIDEO_TEMP"])
111+
temp_dir = str(app.config["VIDEO_TEMP"]),
112+
log_dir = str(app.config["LOG_DIR"]),
112113
)
113114

114115
return {"result_id": result.id}

hackyplayer/formvideo.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def __init__(self, request_id, task_log):
8989
self.file.addHandler(file_handler)
9090

9191

92-
def form_video(task, video, talk, start_tc, end_tc, framerate = FRAMERATE, out_dir = OUT_DIR, temp_dir = TEMP_DIR):
92+
def form_video(task, video, talk, start_tc, end_tc, framerate = FRAMERATE, out_dir = OUT_DIR, temp_dir = TEMP_DIR, log_dir = LOG_DIR):
9393

9494
temp_dir = Path(temp_dir).resolve()
9595
out_dir = Path(out_dir).resolve()
@@ -154,7 +154,7 @@ def form_video(task, video, talk, start_tc, end_tc, framerate = FRAMERATE, out_d
154154
output_path = Path.joinpath(Path(out_dir), output_file)
155155

156156
# Setup log paths
157-
job_log_dir = Path.joinpath(Path(LOG_DIR), Path(str(task.request.id)))
157+
job_log_dir = Path.joinpath(Path(log_dir), Path(str(task.request.id)))
158158
job_log_dir.mkdir(parents=True, exist_ok=True)
159159
build_log = Path.joinpath(job_log_dir, Path("main_build.log"))
160160
loud_log = Path.joinpath(job_log_dir, Path("loudness_analysis.log"))
@@ -283,7 +283,7 @@ def form_video(task, video, talk, start_tc, end_tc, framerate = FRAMERATE, out_d
283283

284284
return str(output_path)
285285

286-
def ingest_video(input_path, output_dir, framerate = FRAMERATE):
286+
def ingest_video(input_path, output_dir, framerate = FRAMERATE, log_dir = LOG_DIR):
287287

288288
start_timestamp = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
289289
input_file = os.path.basename(input_path)
@@ -302,7 +302,7 @@ def ingest_video(input_path, output_dir, framerate = FRAMERATE):
302302
logger.debug(ffmpeg_args)
303303

304304
log_file = Path(input_file + start_timestamp + ".log")
305-
log_path = Path.joinpath(Path(LOG_DIR), log_file)
305+
log_path = Path.joinpath(Path(log_dir), log_file)
306306

307307
with open(log_path, "w+") as error_log:
308308
subprocess.run(ffmpeg_args, stderr=error_log)

hackyplayer/tasks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def build_video(self, *args, **kwargs):
2424
return result
2525

2626
@celery.shared_task(ignore_result=False)
27-
def ingest_video(input_file, output_dir):
28-
result = formvideo.ingest_video(input_file, output_dir)
27+
def ingest_video(input_file, output_dir, log_dir):
28+
result = formvideo.ingest_video(input_file, output_dir, log_dir=log_dir)
2929
return result
3030

3131
@celery.shared_task(base=celery_singleton.Singleton, ignore_result=False)
@@ -77,7 +77,7 @@ def stop_running(signum, frame):
7777
new_file["pass"] = old_file["pass"] + 1
7878
if new_file["pass"] >= 3:
7979
logger.info("'%s': 3 passes with no changes, starting processing", video)
80-
result = ingest_video.delay(str(pathlib.Path.joinpath(watch, pathlib.Path(video))), str(output_dir))
80+
result = ingest_video.delay(str(pathlib.Path.joinpath(watch, pathlib.Path(video))), str(output_dir), log_dir=str(flask_app.config["LOG_DIR"]))
8181
new_file["processing"] = result.id
8282
time.sleep(5)
8383
i += 1

0 commit comments

Comments
 (0)