7

I want to send a video through the API, there are functions to send text, images, audio and documents. Is there a function to send videos or should I use this function to do so?

bot.send_document(chat_id=chat_id, document=open('tests/test.zip', 'rb'))

Is there an easier/more correct way?

Vishnu U
  • 71
  • 1
  • 1
  • 2

1 Answers1

5

The same as with documents

bot.send_video(chat_id=update.message.chat_id, video=open('output.mp4', 'rb'), supports_streaming=True)

send_document can sometimes send video as an actual document file, unplayable in TG

send_video will always send video, playable in TG and also, passing supports_streaming=True will make TG allow to stream before downloading.

More references about send_video and other send_* you can look up at https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/bot.py

To avoid timeout for sending use updater = Updater(token='TOKEN', request_kwargs={'read_timeout': 1000, 'connect_timeout': 1000})

Paxz
  • 2,959
  • 1
  • 20
  • 34
Gleb S
  • 152
  • 2
  • 13