@@ -60,6 +60,22 @@ def cli(log_level: str):
6060MAX_SEGMENT_PADDING = 6
6161
6262
63+ def run_in_bash (
64+ cmd : str ,
65+ capture_output = False ,
66+ check = False ,
67+ text = False ,
68+ shell = False ,
69+ ):
70+ return subprocess .run (
71+ f"/usr/bin/bash -c '{ cmd } '" ,
72+ capture_output = capture_output ,
73+ check = check ,
74+ text = text ,
75+ shell = shell ,
76+ )
77+
78+
6379def nonrepeating_generator (source , desired_length ):
6480 """
6581 Creates a generator that yields one item from `source`
@@ -98,7 +114,7 @@ def get_video_duration(file: Path):
98114 logger .debug (f"Getting file length for { file } " )
99115 try :
100116 return float (
101- subprocess . run (
117+ run_in_bash (
102118 f'ffprobe -v error -show_entries format=duration -of csv=p=0 "{ file } "' ,
103119 capture_output = True ,
104120 check = True ,
@@ -132,7 +148,7 @@ def split_video_segment(
132148):
133149 """Splits a video into segments using ffmpeg."""
134150 logger .debug (f"Splitting { file_name } - segment { idx } " )
135- subprocess . run (
151+ run_in_bash (
136152 f"ffmpeg -nostats -loglevel 0 -y -ss { seconds_to_timestamp (sum (segment_lengths [:idx ]))} "
137153 f'-to { seconds_to_timestamp (sum (segment_lengths [:idx ]) + segment_lengths [idx ])} -i "{ file_name } " '
138154 f'-c copy "{ Path (out_dir , file_name .stem , str (idx ) + file_name .suffix )} "' ,
@@ -144,7 +160,7 @@ def split_video_segment(
144160def get_amplitude_of_segment (clip : Path ):
145161 """Extracts the mean audio amplitude of a video segment."""
146162 logger .debug (f"Analyzing amplitude for clip: { clip } " )
147- res = subprocess . run (
163+ res = run_in_bash (
148164 f'ffmpeg -i "{ Path (CACHE_DIR , clip )} " -filter:a volumedetect -f null -' ,
149165 shell = True ,
150166 check = True ,
@@ -230,7 +246,7 @@ def run_ffmpeg_command(
230246 # filter so that FFmpeg knows where to map the video output.
231247 # TODO: remove that mess and put the same logic in
232248 # build_transition_filters_dynamic
233- subprocess . run (cmd , shell = True , check = True , capture_output = True )
249+ run_in_bash (cmd , shell = True , check = True , capture_output = True )
234250
235251
236252@cli .command ()
@@ -386,7 +402,7 @@ def run(
386402 logger .info ("Creating horizontal video..." )
387403
388404 # Horizontal Pipeline: Take unmarked file and add a semi‑transparent watermark.
389- subprocess . run (
405+ run_in_bash (
390406 f'''ffmpeg -y { decode_options } -i "{ CACHE_DIR / "out-unmarked.mp4" } " -i "{ watermark_image } " \
391407 -filter_complex " \
392408 [1]format=rgba,colorchannelmixer=aa=0.5[logo]; \
@@ -401,7 +417,7 @@ def run(
401417
402418 # Vertical Pipeline: Crop (zoom), split & blur unmarked file for a vertical aspect ratio,
403419 # then overlay a centered, opaque watermark at the bottom.
404- subprocess . run (
420+ run_in_bash (
405421 f'''ffmpeg -y { decode_options } -i "{ CACHE_DIR / "out-unmarked.mp4" } " -i "{ watermark_image } " \
406422 -filter_complex " \
407423 [0]crop=3/4*in_w:in_h[zoomed]; \
0 commit comments