У меня есть script1.py для обработки видео один за другим
Извлечение сохраняется в папке. Br />Output_Videos\namevideo1_Output
< /code>
и второй сценарий мониторинга.py при запуске его отслеживает следующие папки: < /p>
monitoring.py - Мониторинг < /p>
Output_Videos\namevideo1_Output\Images
Output_Videos\namevideo1_Output\Text
< /code>
Но когда Script1.py Обработка второго видео Automatic < /p>
Output_Videos\namevideo1_Output - is complete
Output_Videos\namevideo2_Output
< /code>
script monitoring.py прекращает мониторин Запустите скрипт "monitoring.py" один раз, и он неоднократно проверяет, если какие -либо новые папки output_videos и мониторинг < /p>
Пример < /p>
Output_Videos\namevideo1_Output\Images
Output_Videos\namevideo1_Output\Text
Output_Videos\namevideo2_Output\Images
Output_Videos\namevideo2_Output\Text
Output_Videos\namevideo3_Output\Images
Output_Videos\namevideo3_Output\Text
...
< /code>
monitoring.py
import time
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
from glob import glob
class EventHandler(FileSystemEventHandler):
def __init__(self, text):
self.text = text
def on_created(self, event):
action, path = (event.event_type, event.src_path)
print(self.text.format(path))
def monitor_directories(data):
observer = Observer()
for directory, text in data:
event_handler = EventHandler(text)
observer.schedule(event_handler, directory, recursive=True)
observer.start()
observer = PollingObserver()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()
if __name__ == "__main__":
print("Crop sub area\n")
data = [
# always select a dir path (if using glob, be careful, it returns list), then custom text with {} in it that will become path
[glob("Output_Videos/*/Images")[0], " Crop images [Images] : {} Done"],
[glob("Output_Videos/*/Text")[0], " Crop images [Text] : {} Done"]
]
monitor_directories(data)
Подробнее здесь: https://stackoverflow.com/questions/794 ... nitor-them
Проверьте, являются ли несколько выходных папок новыми, и контролируйте их ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Проверьте, являются ли несколько выходных папок новыми, и контролируйте их
Anonymous » » в форуме Python - 0 Ответы
- 13 Просмотры
-
Последнее сообщение Anonymous
-