18
18
from models .av_mossformer2_tse .faceDetector .s3fd import S3FD
19
19
20
20
from .decode import decode_one_audio_AV_MossFormer2_TSE_16K
21
+ from security import safe_command
21
22
22
23
23
24
@@ -75,20 +76,20 @@ def main(video_args, args):
75
76
else :
76
77
command = ("ffmpeg -y -i %s -qscale:v 2 -threads %d -ss %.3f -to %.3f -async 1 -r 25 %s -loglevel panic" % \
77
78
(video_args .videoPath , video_args .nDataLoaderThread , video_args .start , video_args .start + video_args .duration , video_args .videoFilePath ))
78
- subprocess .call ( command , shell = True , stdout = None )
79
+ safe_command . run ( subprocess .call , command , shell = True , stdout = None )
79
80
sys .stderr .write (time .strftime ("%Y-%m-%d %H:%M:%S" ) + " Extract the video and save in %s \r \n " % (video_args .videoFilePath ))
80
81
81
82
# Extract audio
82
83
video_args .audioFilePath = os .path .join (video_args .pyaviPath , 'audio.wav' )
83
84
command = ("ffmpeg -y -i %s -qscale:a 0 -ac 1 -vn -threads %d -ar 16000 %s -loglevel panic" % \
84
85
(video_args .videoFilePath , video_args .nDataLoaderThread , video_args .audioFilePath ))
85
- subprocess .call ( command , shell = True , stdout = None )
86
+ safe_command . run ( subprocess .call , command , shell = True , stdout = None )
86
87
sys .stderr .write (time .strftime ("%Y-%m-%d %H:%M:%S" ) + " Extract the audio and save in %s \r \n " % (video_args .audioFilePath ))
87
88
88
89
# Extract the video frames
89
90
command = ("ffmpeg -y -i %s -qscale:v 2 -threads %d -f image2 %s -loglevel panic" % \
90
91
(video_args .videoFilePath , video_args .nDataLoaderThread , os .path .join (video_args .pyframesPath , '%06d.jpg' )))
91
- subprocess .call ( command , shell = True , stdout = None )
92
+ safe_command . run ( subprocess .call , command , shell = True , stdout = None )
92
93
sys .stderr .write (time .strftime ("%Y-%m-%d %H:%M:%S" ) + " Extract the frames and save in %s \r \n " % (video_args .pyframesPath ))
93
94
94
95
# Scene detection for the video frames
@@ -135,7 +136,7 @@ def main(video_args, args):
135
136
command += f"ffmpeg -i { file [:- 9 ]} orig_{ idx } .mp4 -i { file [:- 9 ]} est_{ idx } .wav -c:v copy -map 0:v:0 -map 1:a:0 -shortest { file [:- 9 ]} est_{ idx } .mp4 ;"
136
137
# command += f"rm {file[:-9]}est_{idx}.wav ;"
137
138
138
- output = subprocess .call ( command , shell = True , stdout = None )
139
+ output = safe_command . run ( subprocess .call , command , shell = True , stdout = None )
139
140
140
141
rmtree (video_args .pyworkPath )
141
142
rmtree (video_args .pyframesPath )
@@ -259,11 +260,11 @@ def crop_video(video_args, track, cropFile):
259
260
vOut .release ()
260
261
command = ("ffmpeg -y -i %s -async 1 -ac 1 -vn -acodec pcm_s16le -ar 16000 -threads %d -ss %.3f -to %.3f %s -loglevel panic" % \
261
262
(video_args .audioFilePath , video_args .nDataLoaderThread , audioStart , audioEnd , audioTmp ))
262
- output = subprocess .call ( command , shell = True , stdout = None ) # Crop audio file
263
+ output = safe_command . run ( subprocess .call , command , shell = True , stdout = None ) # Crop audio file
263
264
_ , audio = wavfile .read (audioTmp )
264
265
command = ("ffmpeg -y -i %st.avi -i %s -threads %d -c:v copy -c:a copy %s.avi -loglevel panic" % \
265
266
(cropFile , audioTmp , video_args .nDataLoaderThread , cropFile )) # Combine audio and video file
266
- output = subprocess .call ( command , shell = True , stdout = None )
267
+ output = safe_command . run ( subprocess .call , command , shell = True , stdout = None )
267
268
os .remove (cropFile + 't.avi' )
268
269
return {'track' :track , 'proc_track' :dets }
269
270
@@ -338,7 +339,7 @@ def visualization(tracks, est_sources, video_args):
338
339
command = ("ffmpeg -y -i %s -i %s -threads %d -c:v copy -c:a copy %s -loglevel panic" % \
339
340
(os .path .join (video_args .pyaviPath , 'video_only.avi' ), (video_args .pycropPath + '/est_%s.wav' % tidx ), \
340
341
video_args .nDataLoaderThread , os .path .join (video_args .pyaviPath ,'video_out_%s.avi' % tidx )))
341
- output = subprocess .call ( command , shell = True , stdout = None )
342
+ output = safe_command . run ( subprocess .call , command , shell = True , stdout = None )
342
343
343
344
344
345
@@ -348,7 +349,7 @@ def visualization(tracks, est_sources, video_args):
348
349
os .path .join (video_args .pyaviPath , 'video_est_%s.mp4' % tidx )
349
350
)
350
351
command += f"rm { os .path .join (video_args .pyaviPath , 'video_out_%s.avi' % tidx )} "
351
- output = subprocess .call ( command , shell = True , stdout = None )
352
+ output = safe_command . run ( subprocess .call , command , shell = True , stdout = None )
352
353
353
354
354
355
command = "ffmpeg -i %s %s ;" % (
@@ -358,4 +359,4 @@ def visualization(tracks, est_sources, video_args):
358
359
command += f"rm { os .path .join (video_args .pyaviPath , 'video_only.avi' )} ;"
359
360
command += f"rm { os .path .join (video_args .pyaviPath , 'video.avi' )} ;"
360
361
command += f"rm { os .path .join (video_args .pyaviPath , 'audio.wav' )} ;"
361
- output = subprocess .call ( command , shell = True , stdout = None )
362
+ output = safe_command . run ( subprocess .call , command , shell = True , stdout = None )
0 commit comments