fix audio in video encoding

This commit is contained in:
bakatrouble 2023-09-08 03:59:42 +03:00
parent d7b01d68f6
commit d1390d73b8

20
main.py
View File

@ -65,17 +65,15 @@ async def send_post(post: E621Post, tag_list: List[str]):
mp4_path = Path(td) / 'video.mp4'
with open(src_path, 'wb') as webm:
webm.write(file.read())
ffmpeg\
.input(str(src_path)) \
.filter('pad', **{
'width': 'ceil(iw/2)*2',
'height': 'ceil(ih/2)*2',
'x': '0',
'y': '0',
'color': 'Black'
})\
.output(str(mp4_path), vcodec='libx264', crf='26')\
.run()
video_input = ffmpeg\
.input(str(src_path))
cmd = video_input \
.output(str(mp4_path),
vf='pad=width=ceil(iw/2)*2:height=ceil(ih/2)*2:x=0:y=0:color=Black',
vcodec='libx264',
crf='26')
logging.info('ffmpeg ' + ' '.join(cmd.get_args()))
cmd.run()
s3 = boto3.client('s3', aws_access_key_id=os.environ['AWS_ACCESS_KEY'], aws_secret_access_key=os.environ['AWS_SECRET_KEY'])
bucket = os.environ['AWS_S3_BUCKET']
upload_filename = f'e621-{post.id}-{int(time())}.mp4'