| 74 | args.savePath = os.path.join(args.videoFolder, args.videoName) |
| 75 | |
| 76 | def scene_detect(args): |
| 77 | # CPU: Scene detection, output is the list of each shot's time duration |
| 78 | videoManager = VideoManager([args.videoFilePath]) |
| 79 | statsManager = StatsManager() |
| 80 | sceneManager = SceneManager(statsManager) |
| 81 | sceneManager.add_detector(ContentDetector()) |
| 82 | baseTimecode = videoManager.get_base_timecode() |
| 83 | videoManager.set_downscale_factor() |
| 84 | videoManager.start() |
| 85 | sceneManager.detect_scenes(frame_source = videoManager) |
| 86 | sceneList = sceneManager.get_scene_list(baseTimecode) |
| 87 | savePath = os.path.join(args.pyworkPath, 'scene.pckl') |
| 88 | if sceneList == []: |
| 89 | sceneList = [(videoManager.get_base_timecode(),videoManager.get_current_timecode())] |
| 90 | with open(savePath, 'wb') as fil: |
| 91 | pickle.dump(sceneList, fil) |
| 92 | sys.stderr.write('%s - scenes detected %d\n'%(args.videoFilePath, len(sceneList))) |
| 93 | return sceneList |
| 94 | |
| 95 | def inference_video(args): |
| 96 | # GPU: Face detection, output is the list contains the face location and score in this frame |