Advertisement
Guest User

Untitled

a guest
Aug 4th, 2022
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. import subprocess
  2. import os
  3. import glob
  4. from pathlib import Path
  5. #takes in 9 input youtube videos and creates an output named 'output.webm'
  6.  
  7. LENGTH = 7 #length of each clip
  8. totallength = LENGTH*9
  9. #input videos, must be square, must be 9 videos
  10. #second value is the start time of the audio clip in seconds, adjust to desired time
  11. videos = [
  12. ("INSERT VIDEO 1 URL", 25),
  13. ("INSERT VIDEO 2 URL", 25),
  14. ("INSERT VIDEO 3 URL", 25),
  15. ("INSERT VIDEO 4 URL", 25),
  16. ("INSERT VIDEO 5 URL", 25),
  17. ("INSERT VIDEO 6 URL", 25),
  18. ("INSERT VIDEO 7 URL", 25),
  19. ("INSERT VIDEO 8 URL", 25),
  20. ("INSERT VIDEO 9 URL", 25)
  21. ]
  22. if not os.path.isdir('videos'):
  23. os.mkdir('videos')
  24. count = 0
  25. for vid in videos:
  26. subprocess.run(["youtube-dl", "-o",f"videos/{count}.%(ext)s",vid[0]])
  27. count += 1
  28.  
  29. files = sorted(list(map(lambda x: str(Path(x)),glob.glob("./videos/*.*"))))
  30.  
  31. subprocess.run([
  32. "ffmpeg", "-i", files[0], "-i", files[1], "-i", files[2], "-i", files[3], "-i", files[4], "-i", files[5], "-i", files[6], "-i", files[7], "-i", files[8],
  33. "-filter_complex", '[0:v]scale=300:300[a];[1:v]scale=300:300[b];[2:v]scale=300:300[c];[3:v]scale=300:300[d];[4:v]scale=300:300[e];[5:v]scale=300:300[f];[6:v]scale=300:300[g];[7:v]scale=300:300[h];[8:v]scale=300:300[i];' +
  34. f'[0:a]atrim={videos[0][1]}:{videos[0][1]+7}[j];[1:a]atrim={videos[1][1]}:{videos[1][1]+7}[k];[2:a]atrim={videos[2][1]}:{videos[2][1]+7}[l];[3:a]atrim={videos[3][1]}:{videos[3][1]+7}[m];[4:a]atrim={videos[4][1]}:{videos[4][1]+7}[n];[5:a]atrim={videos[5][1]}:{videos[5][1]+7}[o];[6:a]atrim={videos[6][1]}:{videos[6][1]+7}[p];[7:a]atrim={videos[7][1]}:{videos[7][1]+7}[q];[8:a]atrim={videos[8][1]}:{videos[8][1]+7}[r];' +
  35. '[j][k][l][m][n][o][p][q][r]concat=n=9:v=0:a=1[s];' +
  36. f'[a][b][c]hstack=inputs=3[t]; [d][e][f]hstack=inputs=3[u]; [g][h][i]hstack=inputs=3[v]; [t][u][v]vstack=inputs=3[w]; [w]setpts=N/FRAME_RATE/TB[x]; [x]trim=0:{totallength}[y]; [s]asetpts=N/SR/TB[z]',
  37. '-map', '[y]', '-map', '[z]', '-c:a', 'libvorbis', '-c:v', 'libvpx', "-q:a","6","-b:v","1000k","-shortest", 'output3.webm'
  38. ])
  39.  
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement