Guest User

Untitled

a guest
Apr 26th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import os
  2. import subprocess as sp
  3. import sys
  4.  
  5. '''
  6. requirements:
  7. - python3
  8. - ffmpeg
  9.  
  10. ・正方形の絵とwavファイルを用意する。
  11. ・二分間の動画ができる。
  12. '''
  13.  
  14. class Settings:
  15. ffmpeg = "<.../ffmpeg.exe>"
  16. music = "<.../music.wav>"
  17. picture = "<.../square_pict.jpg>"
  18. name = "<movie_name>"
  19. output_path = "<...>"
  20.  
  21. def shell(cmd):
  22. sp.call(cmd,shell=True)
  23. #sp.check_output(cmd,shell=True,stderr=sp.STDOUT)
  24.  
  25. def ffmpeg():
  26. print(" : START")
  27. s = Settings()
  28. cmd = '''\
  29. {s.ffmpeg} -loop 1 \
  30. -i "{s.picture}" \
  31. -i "{s.music}" \
  32. -c:v libx264 \
  33. -pix_fmt yuv420p \
  34. -t 00:02:00 \
  35. -tune stillimage -preset medium -crf 18 -movflags +faststart \
  36. -c:a aac -ab 384k -ar 48000 -ac 2 \
  37. -r 30 -s 640x640 -aspect 1:1 \
  38. -shortest "{s.output_path}/{s.name}.mp4" \
  39. -y -threads 8\
  40. '''.format(**locals())
  41. shell( cmd )
  42. print(" : ENCODED")
  43.  
  44. def main():
  45. ffmpeg()
  46.  
  47. if __name__ == "__main__" :
  48. main()
Add Comment
Please, Sign In to add comment