mover.py 783 B

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