MCPcopy Create free account
hub / github.com/TaoRuijie/TalkNet-ASD / main

Function main

demoTalkNet.py:353–455  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

351
352# Main function
353def main():
354 # This preprocesstion is modified based on this [repository](https://github.com/joonson/syncnet_python).
355 # ```
356 # .
357 # ├── pyavi
358 # │   ├── audio.wav (Audio from input video)
359 # │   ├── video.avi (Copy of the input video)
360 # │   ├── video_only.avi (Output video without audio)
361 # │   └── video_out.avi (Output video with audio)
362 # ├── pycrop (The detected face videos and audios)
363 # │ ├── 000000.avi
364 # │ ├── 000000.wav
365 # │ ├── 000001.avi
366 # │ ├── 000001.wav
367 # │ └── ...
368 # ├── pyframes (All the video frames in this video)
369 # │ ├── 000001.jpg
370 # │ ├── 000002.jpg
371 # │ └── ...
372 # └── pywork
373 # ├── faces.pckl (face detection result)
374 # ├── scene.pckl (scene detection result)
375 # ├── scores.pckl (ASD result)
376 # └── tracks.pckl (face tracking result)
377 # ```
378
379 # Initialization
380 args.pyaviPath = os.path.join(args.savePath, 'pyavi')
381 args.pyframesPath = os.path.join(args.savePath, 'pyframes')
382 args.pyworkPath = os.path.join(args.savePath, 'pywork')
383 args.pycropPath = os.path.join(args.savePath, 'pycrop')
384 if os.path.exists(args.savePath):
385 rmtree(args.savePath)
386 os.makedirs(args.pyaviPath, exist_ok = True) # The path for the input video, input audio, output video
387 os.makedirs(args.pyframesPath, exist_ok = True) # Save all the video frames
388 os.makedirs(args.pyworkPath, exist_ok = True) # Save the results in this process by the pckl method
389 os.makedirs(args.pycropPath, exist_ok = True) # Save the detected face clips (audio+video) in this process
390
391 # Extract video
392 args.videoFilePath = os.path.join(args.pyaviPath, 'video.avi')
393 # If duration did not set, extract the whole video, otherwise extract the video from 'args.start' to 'args.start + args.duration'
394 if args.duration == 0:
395 command = ("ffmpeg -y -i %s -qscale:v 2 -threads %d -async 1 -r 25 %s -loglevel panic" % \
396 (args.videoPath, args.nDataLoaderThread, args.videoFilePath))
397 else:
398 command = ("ffmpeg -y -i %s -qscale:v 2 -threads %d -ss %.3f -to %.3f -async 1 -r 25 %s -loglevel panic" % \
399 (args.videoPath, args.nDataLoaderThread, args.start, args.start + args.duration, args.videoFilePath))
400 subprocess.call(command, shell=True, stdout=None)
401 sys.stderr.write(time.strftime("%Y-%m-%d %H:%M:%S") + " Extract the video and save in %s \r\n" %(args.videoFilePath))
402
403 # Extract audio
404 args.audioFilePath = os.path.join(args.pyaviPath, 'audio.wav')
405 command = ("ffmpeg -y -i %s -qscale:a 0 -ac 1 -vn -threads %d -ar 16000 %s -loglevel panic" % \
406 (args.videoFilePath, args.nDataLoaderThread, args.audioFilePath))
407 subprocess.call(command, shell=True, stdout=None)
408 sys.stderr.write(time.strftime("%Y-%m-%d %H:%M:%S") + " Extract the audio and save in %s \r\n" %(args.audioFilePath))
409
410 # Extract the video frames

Callers 1

demoTalkNet.pyFile · 0.70

Calls 7

scene_detectFunction · 0.85
inference_videoFunction · 0.85
track_shotFunction · 0.85
crop_videoFunction · 0.85
evaluate_networkFunction · 0.85
evaluate_col_ASDFunction · 0.85
visualizationFunction · 0.85

Tested by

no test coverage detected