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