'TypeError: a bytes-like object is required, not 'OutputStream'

after sending the video to the bot, I get the following error: TypeError: a bytes-like object is required, not 'OutputStream'

It throws 14 line: "with open(file_name, 'wb') as new_file:"

import ffmpeg
import telebot

myID = 'MyTelegramId'

bot = telebot.TeleBot("telegram_token", parse_mode=None)

@bot.message_handler(content_types=['document', 'photo', 'audio', 'video', 'voice'])
def addfile(message):
    file_name = message.video.file_name
    file_info = bot.get_file(message.video.file_id)
    downloaded_file = bot.download_file(file_info.file_path)
    downloaded_file = ffmpeg.input(downloaded_file).filter('hflip').filter('contrast', contrast=0.9).filter('gamma_b', gamma_b=1.3).filter('saturation', saturation=1).output('out.mp4')
    with open(file_name, 'wb') as new_file:
        new_file.write(downloaded_file)
    bot.send_video(myID, file_name)
        

bot.infinity_polling()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source