recursiveacronymvideo.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/usr/bin/env python
  2. # WHAT IS THIS?
  3. # On wikipedia I copied and pasted there list of recursive acronyms
  4. # e.g. GNU (GNUs not Unix) or YAML (YAML ain't Markup Language). Then
  5. # I went to the internet and searched how to make text on a certain
  6. # background with ffmpeg. Once I did that I ran it on all of the
  7. # recursive acronyms. So a lot of 10 second videos. Then I concat them
  8. # into just one, and then finally put on free none copyright music I
  9. # found on invidious. This was inspired by Roel van de Par's videos of
  10. # various stackexchange questions and answers he pumps out basicly
  11. # every 5 minutes on his chanel.
  12. import os
  13. import random
  14. acronyms = """BWIA - BWIA West Indies Airways
  15. VISA - Visa International Service Association
  16. SAAB - Saab Automobile AB
  17. Cygnus Solutions - Cygnus, Your GNU Solutions
  18. Allegro - Allegro Low LEvel Game ROutines
  19. AROS - AROS Research Operating System
  20. ATI - ATI Technologies Inc.
  21. BIRD - BIRD Internet Routing Daemon
  22. CAVE - CAVE Automatic Virtual Environment
  23. cURL - Curl URL Request Library
  24. Darcs - Darcs Advanced Revision Control System
  25. EINE - EINE Is Not Emacs
  26. FIJI - FIJI Is Just ImageJ
  27. GiNaC - GiNaC is Not a CAS
  28. GNU - GNU's Not Unix
  29. GPE - GPE Palmtop Environment
  30. gRPC - grpc Remote Procedure Calls
  31. HIJOS - Hijos por la Identidad y la Justicia contra el Olvido y el Silencio
  32. HIM - HIM International Music, Taiwanese independent record label
  33. JACK - JACK Audio Connection Kit
  34. KGS - KGS Go Server
  35. LAME - LAME Ain't an MP3 Encoder
  36. LiVES - LiVES is a Video Editing System
  37. MEGA - MEGA Encrypted Global Access
  38. MIATA - MIATA is Always the Answer
  39. MINT - MINT Is Not TRAC
  40. Mung - Mung Until No Good
  41. Nano - Nano's Another editor
  42. Nagios - Nagios Ain't Gonna Insist On Sainthood
  43. NiL - NiL Isn't Liero
  44. Ninja-ide - Ninja-IDE Is Not Just Another IDE
  45. PHP - PHP Hypertext Preprocessor
  46. PINE - PINE Is Nearly Elm
  47. PIP - PIP Installs Packages
  48. P.I.P.S. - P.I.P.S. Is POSIX on Symbian
  49. PNG - PNG's not GIF
  50. RPM - RPM Package Manager
  51. SPARQL - SPARQL Protocol And RDF Query Language
  52. TikZ - TikZ ist kein Zeichenprogramm
  53. TiLP - TiLP is a Linking Program
  54. TIP - TIP isn't Pico
  55. TRESOR - TRESOR Runs Encryption Securely Outside RAM
  56. UIRA - UIRA Isn't a Recursive Acronym
  57. WINE - WINE Is Not an Emulator
  58. XAMPP - XAMPP Apache MariaDB PHP Perl
  59. XBMC - XBMC Media Center
  60. XINU - XINU Is Not Unix
  61. XNA - XNA's Not Acronymed
  62. XNU - X is Not Unix
  63. YAML - YAML Ain't Markup Language
  64. ZINC - ZINC Is Not Commercial
  65. Zinf - Zinf Is Not FreeAmp
  66. ZWEI - ZWEI Was EINE Initially"""
  67. # Create the recursive acronym 5 second videos
  68. audio = "music.opus"
  69. acronyms = acronyms.splitlines()
  70. for acronym in acronyms:
  71. color = ["#"+''.join([random.choice('0123456789ABCDEF') for j in range(6)])][0]
  72. name = acronym.split(" - ")[0].replace(" ","_").lower()
  73. command = f"ffmpeg -f lavfi -i color=size=1920x1080:rate=25:color={color} -vf \"drawtext=fontsize=45:fontcolor=#000000:x=(w-text_w)/2:y=(h-text_h)/2:text='{acronym}'\" -c:a copy -t 00:00:05 -shortest {name}.mp4"
  74. os.system(command)
  75. # concat all the acronym 5 second videos
  76. files = os.listdir()
  77. for file in files:
  78. if file.endswith(".mp4"):
  79. with open("list.txt","a") as f:
  80. f.write(f"\nfile '{file}'")
  81. os.system("ffmpeg -f concat -i list.txt -c copy input.mp4")
  82. for file in files:
  83. if file.endswith(".mp4"):
  84. os.remove(file)
  85. # add some audio to the final video (This is CPU/GPU hungry)
  86. command = f"ffmpeg -i input.mp4 -i {audio} -filter_complex \" [1:0] apad \" -shortest output.mp4"
  87. os.system(command)
  88. os.remove("input.mp4")
  89. os.remove("list.txt")