train_video.py 938 B

12345678910111213141516171819202122232425262728
  1. import os
  2. import subprocess
  3. # 视频绝对路径
  4. video_path = r"E:\BaiduNetdiskDownload\gaussian-splatting\gaussian-splatting\data\table\table.mp4"
  5. # 切分帧数,每秒多少帧
  6. fps = 2
  7. # 获取当前工作路径
  8. current_path = os.getcwd()
  9. # 上一级文件夹所在路径
  10. folder_path = os.path.dirname(video_path)
  11. # 图片保存路径
  12. images_path = os.path.join(folder_path, 'input')
  13. os.makedirs(images_path, exist_ok=True)
  14. ffmpeg_path = os.path.join(current_path, 'external', r'ffmpeg/bin/ffmpeg.exe')
  15. # 脚本运行
  16. # 视频切分脚本
  17. command = f'{ffmpeg_path} -i {video_path} -qscale:v 1 -qmin 1 -vf fps={fps} {images_path}\\%04d.jpg'
  18. subprocess.run(command, shell=True)
  19. # COLMAP估算相机位姿
  20. command = f'python convert.py -s {folder_path}'
  21. subprocess.run(command, shell=True)
  22. # 模型训练脚本,模型会保存在output路径下
  23. # command = f'python train.py -s {folder_path}'
  24. # subprocess.run(command, shell=True)