How about sending a GIF?
Might be to short? Sometimes the movement captured is about 30-40seconds at 30fps.
In telegram bot api there is note about video size. Files must be below 50MB. Maybe your file is above that limit?
They’re all under 10Mb - think I found it - I had a 30 second delay before sending the video - I’ve now changed that to 60 seconds, and they’re coming through.
Found the issue in the logs.
This happens frequently on files being sent:
Error sending file: urllib3 HTTPError (‘Connection aborted.’, timeout(‘The write operation timed out’,)).
Has anyone managed to solve this problem? one hour works another time does not work … I only receive this msg.
Error sending file: urllib3 HTTPError ('Connection aborted.', timeout('The write operation timed out',)). Args: (543056216, <_io.BufferedReader name='/tmp/shot1.mp4'>), kwargs: {'caption': 'Campainha', 'parse_mode': 'Markdown', 'disable_notification': False, 'disable_web_page_preview': None, 'reply_to_message_id': None, 'reply_markup': None, 'timeout': None}
18:45 components/telegram_bot/__init__.py (ERROR)
Jea. Here too - Got it resolfed in the last monts?
[homeassistant.components.telegram_bot]
Error sending file: urllib3 HTTPError
('Connection aborted.', timeout('The write operation timed out',)).
Args: (42026658, <_io.BufferedReader name='/tmp/shot1.mp4'>),
kwargs: {'disable_web_page_preview': None, 'timeout': None, 'disable_notification':
False, 'reply_to_message_id': None, 'parse_mode': 'Markdown', 'reply_markup': None, 'caption': 'Video Title xy'}
Hi I have exactly the same problem (timeout error), did you find the solution ?
c.a. - I made an shell script wich reccords a video stream with ffmpeg. Keeps the size under 1.5mb for 5 secconds and I can send it via telegram - this is for the Android app IP Webcam
shell script:
#!/bin/bash
date
folder=/config/ffmpeg
id=$(date +"%y-%m-%d_%H-%M-%S")
rtsp_url=http://user:[email protected]:8080/video?profile=0
duration=5
bitrate=2048k
codec=libx264
filesize=2048k
echo "$id.mp4" >/config/ffmpeg/file.txt
ffmpeg -y -i $rtsp_url -t $duration -b:v $bitrate -vcodec $codec -fs $filesize $folder/$id.mp4
echo "1" >/config/ffmpeg/done.txt
find $folder -type f -name '*.mp4' -mtime +30 -exec rm {} \;
sleep 20s
echo "0" >/config/ffmpeg/done.txt
cam Package for the filename and wait template
shell_command:
ipcam_sh: bash -x /config/shell_scripts/cam.sh >> /share/ipcam2.log 2>&1
sensor:
- platform: file
name: cam_file
file_path: /config/ffmpeg/file.txt
- platform: file
name: cam_done
file_path: /config/ffmpeg/done.txt
Telegram action:
action:
- service: shell_command.ipcam_sh
- wait_template: "{{ is_state('sensor.cam_done', '1') }}"
timeout: '00:00:40'
continue_on_timeout: 'true'
- service: telegram_bot.send_video
data_template:
file: /config/ffmpeg/{{ states('sensor.cam_file')}}
- service: telegram_bot.send_message
data_template:
target: 'xxxxxxxx'
message: " Stand: {{ states('sensor.cam_file')}} Es ist {{now().strftime('%H:%M:%S %Y-%m-%d')}} /vid um es noch mal zu senden."
you have to whitelist the folders you use - Otherwise you get an error
Hi @Underknowledge,
Thanks for your code. Can this work with lookback?
I currently use camera.record
service which works great on my ONVIF entity but sometimes the file is slightly too big for telegram.
Thats exactly why I used the ffmpg shell script. you can throw it a 800 mb file and ll vonvert it down to the 2mb.
in your case you ither have to find out the straming url ore reformat your created file,
Ok! Thanks. Does it include a capability for lookback?
I have no clue what you mean with loopback.
It definitely works via 127.0.0.1 when you mean this.
What I mean is that you put for instance 30 seconds in loopback and a minute duration and the video which will be sent will be a minute long and will start 30 seconds before your script was triggered.