mover.py 828 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env python3
  2. import os
  3. from db import db,file_info
  4. from subprocess import Popen,PIPE
  5. from constants import RAW_PATH,INCOMING_PATH
  6. d=db()
  7. for fname in os.listdir(INCOMING_PATH):
  8. if fname.endswith("flv"):
  9. out_fname=os.path.join(RAW_PATH, os.path.basename(fname).replace('flv','mp4'))
  10. in_fname=os.path.join(INCOMING_PATH, fname)
  11. if os.path.isfile(out_fname):
  12. #exists
  13. continue
  14. process=[ 'ffmpeg',
  15. '-loglevel', 'error',
  16. '-i', in_fname,
  17. '-c', 'copy',
  18. '-movflags', '+faststart',
  19. '-f','mp4',
  20. out_fname
  21. ]
  22. print(" ".join(process))
  23. proc=Popen(process, universal_newlines=True)
  24. proc.wait()
  25. d.insert_raw(file_info(out_fname))