gallerympv.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env python
  2. import os
  3. from pathlib import Path
  4. dir = "C:\\SGZ_Pro\\Hobbys\\Media\\xy\\thumbnails\\"
  5. files2 = sorted(Path(dir).iterdir(), key=os.path.getmtime)
  6. files = os.listdir(dir)
  7. nums = list(range(int(len(files))))
  8. vidbrack = []
  9. for num in nums:
  10. vidbrack.append(f"[vid{num}]")
  11. def divide_chunks(l,n):
  12. for i in range(0, len(l), n):
  13. yield l[i:i +n]
  14. chunks = list(divide_chunks(vidbrack[1:],10))
  15. external_file = dir+files[0]
  16. t = ""
  17. num = 0
  18. lafvi = ""
  19. for file in files2:
  20. external_file = external_file+f' --external-file="{file}"'
  21. for i, file in enumerate(files[1:]):
  22. if (i % 3):
  23. num = num+1
  24. t = t+f"[t{num}]"
  25. lafvi = lafvi+''.join(chunks[num-1])+f"hstack=inputs=10[t{num}];"
  26. elif i == 3:
  27. break
  28. inputs = i+1
  29. vidbrack = ''.join(vidbrack)
  30. command = f'mpv --lavfi-complex="{lafvi}{t} vstack [vo]" {external_file}'
  31. print(command)
  32. os.system(command)
  33. #command = f'mpv --lavfi-complex="{vidbrack}hstack=inputs={inputs}[vo]" {external_file}'
  34. #command = f'mpv --lavfi-complex="[vid1][vid2][vid3]hstack=inputs=3[t1];[vid10][vid5][vid6]hstack=inputs=3[t2];{t} vstack [vo]" {external_file}'