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?

asked Dec 3, 2017 at 6:38
2
  • So implementing via bot.send_document works, however it returns a timeout error Commented Dec 4, 2017 at 4:03
  • pass timeout=20 to the same method to override the default timeout, or even increase the number more Commented Dec 5, 2017 at 5:40

1 Answer 1

6

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
3,0671 gold badge22 silver badges36 bronze badges
answered Jul 2, 2018 at 12:45
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.