Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import subprocess as sp
- import sys
- '''
- requirements:
- - python3
- - ffmpeg
- ・正方形の絵とwavファイルを用意する。
- ・二分間の動画ができる。
- '''
- class Settings:
- ffmpeg = "<.../ffmpeg.exe>"
- music = "<.../music.wav>"
- picture = "<.../square_pict.jpg>"
- name = "<movie_name>"
- output_path = "<...>"
- def shell(cmd):
- sp.call(cmd,shell=True)
- #sp.check_output(cmd,shell=True,stderr=sp.STDOUT)
- def ffmpeg():
- print(" : START")
- s = Settings()
- cmd = '''\
- {s.ffmpeg} -loop 1 \
- -i "{s.picture}" \
- -i "{s.music}" \
- -c:v libx264 \
- -pix_fmt yuv420p \
- -t 00:02:00 \
- -tune stillimage -preset medium -crf 18 -movflags +faststart \
- -c:a aac -ab 384k -ar 48000 -ac 2 \
- -r 30 -s 640x640 -aspect 1:1 \
- -shortest "{s.output_path}/{s.name}.mp4" \
- -y -threads 8\
- '''.format(**locals())
- shell( cmd )
- print(" : ENCODED")
- def main():
- ffmpeg()
- if __name__ == "__main__" :
- main()
Add Comment
Please, Sign In to add comment