You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 rivejä
935 B

  1. """
  2. video.py h265[h264]
  3. """
  4. import sys
  5. import subprocess
  6. import time
  7. import os
  8. DAT_FOLDER = "/media-file/origin"
  9. TARGET_FOLDER="/media-file/camera"
  10. SUFFIX=".dat"
  11. TARGET_SUFFIX=".mp4"
  12. codec = "h265"
  13. if(len(sys.argv)>1):
  14. codec=sys.argv[1]
  15. # timeout=sys.argv[2]
  16. print("codec:: %s" %codec)
  17. current_time=time.strftime(time.strftime("%Y-%m-%d-%H"),time.localtime())
  18. file_list = os.listdir(DAT_FOLDER)
  19. if file_list:
  20. for dat in file_list:
  21. if current_time+".dat" == dat:
  22. print("%s ignore" %dat)
  23. continue
  24. status, output = subprocess.getstatusoutput("ffmpeg -i " + os.path.join(DAT_FOLDER,dat) + " -c copy " + os.path.join(TARGET_FOLDER, codec, dat.split(".")[0], TARGET_SUFFIX))
  25. if status==0:
  26. print("%s convert sucessfull" %dat)
  27. os.remove(os.path.join(DAT_FOLDER,dat))
  28. else:
  29. print("%s convert fail" %dat)
  30. else:
  31. print("folder is empty")