I am making a telegram bot to upload videos in my local PC. But when I sent the video, that message is very dumb. like this
Image 1
But I need videos like this
Image 2
Image 3
my code is
from pyrogram import Client
app = Client(
"session",
api_id=329,
api_hash="7943a36fdcf9"
)
with app:
app.send_video(chat_id = channel, video = 'vid.mp4',supports_streaming = True)
is there any specific specific methods for sending a proper video? How can I send a video properly
Your video file is too big. Telegram will handle videos < 10 MB and automatically create a thumbnail for you. For videos larger than that you'll have to supply the information about the video yourself. Resolution (width and height), length, thumbnail, etc..
Additionally, you can omit the supports_streaming argument, as Pyrogram defaults this to True anyway.
To get information about your video you could use something like ffprobe.
The docs show that you can add arguments caption and thumb to your call to send_video.
Related
I am creating a "Youtube Clone" using Python Flask on the backend and React JS on the server side, and I currently need to stream the video from a file on the server.
This is what I currently have:
#app.route('/api/video/<string:video_id>')
def ShowVideo(video_id):
video = Video.query.filter_by(id = video_id).first() #"Video" is the video database (using SQLAlchemy)
if video is None:
return {"return":"401"} #video doesn't exist in database
#return ??
now I have the video id and path in the database, and I need to stream it over http to a React JS website
I've seen people using OpenCV to stream, and put an image in the JS client, but from what I've seen it does not work with a video file already on the computer (I can be mistaken, I'm not sure).
Another thing I've seen is using JS to send the video directly to the browser (like in this video, but I don't think this will work for my circumstances)
Does anyone have any idea?
Is it possible to download images from a private telegram channel without admin rights using Python?
Basically what I want is the script to wait till a picture is sent in the private channel and if one got sent, I want it download the picture with the filename increasing(img1, img2...). Problem is I dont have admin rights in this channel and no Bot.
Sure. If you have access to this channel, you can use the "telethon" library to implement this function.
https://docs.telethon.dev/en/stable/
The first thing you have to do is get a channel
input_entity = await UserMethods.get_input_entity(client, peer="https://t.me/example")
entity = await client.get_entity(input_entity)
and then:
client.download_profile_photo(entity, file=photo_path)
I am planning to write my own live stream server in python using the HLS protocol for a small project.
My idea is to use Amazon S3 for storage and have the python server just output the m3u8 file.
This is all straightforward, now to the problem: I want to stream live video from a camera over an unreliable network and if there is a congestion the player could end up with completing playing of the last file referenced in the m3u8 file. Can i in some way mark the stream as a live stream having the player try again reloading the m3u8 for a specific time looking for a next segment or how should live streaming using HLS be handled?
Maybe live streaming over HLS is not supported?
This is explictly allowed in the HLS spec as a "live Playlist". There are a few things you need to be aware of, but notably, from section 6.2.1:
The server MUST NOT change the Media Playlist file, except to:
o Append lines to it (Section 6.2.1).
And if we take a look at Section 4.3.3.4:
The EXT-X-ENDLIST tag indicates that no more Media Segments will be added to the Media Playlist file. It MAY occur anywhere in the Media Playlist file.
In other words, if a playlist does not include the #EXT-X-ENDLIST tag, it's expected that the player will keep loading the playlist from whatever source it originally loaded it from with some frequency, looking for the server to append segments to the playlist.
Most players will do this taking into account current network conditions so they have a chance to get new segments before the playback is caught up. If the server needs to interrupt the segments, or otherwise introduce a gap, it has the responsibility to introduce a #EXT-X-DISCONTINUITY-SEQUENCE tag.
Apple provides a more concrete example of a Live Playlist on their developer website.
I am trying to make telegram bot using library python-telegram-bot. One of the features of my bot is to send Instagram’s stories to the user. For this feature I am using method sendMediaGroup with several InputMediaVideo or InputMediaPhoto in the input.
For example (Instagram link is available only for 24 hours, perhaps at the time you read this, it is no longer valid):
def input_media_group_test(update: Update, context: CallbackContext):
update.message.bot.sendMediaGroup(
update.message.chat.id,
[
InputMediaVideo('https://scontent-hel3-1.cdninstagram.com/v/t50.2886-16/88545009_217343653444163_3673202947982720032_n.mp4?efg=eyJ2ZW5jb2RlX3RhZyI6InZ0c192b2RfdXJsZ2VuLjcyMC5zdG9yeS5kZWZhdWx0In0&_nc_ht=scontent-hel3-1.cdninstagram.com&_nc_cat=111&_nc_ohc=2Hc1-g9OjDEAX85a-aD&vs=17858017211381000_2586017057&_nc_vs=HBkcFQAYJEdQRVdSd1ZEX2tGRHJNVUFBQ0I4YmFhZTF2a3lidXFIQUFBQRUAAsgBACgAGAAbAYgHdXNlX29pbAExFQAAJpCr%2B6S08bg%2FFQIoAkMzLBdAFAAAAAAAABgSZGFzaF9iYXNlbGluZV8xX3YxEQB16AcA&_nc_rid=ce28126395&oe=60068925&oh=46f6f85c7e36f37b578c7319a70191bc'),
InputMediaVideo('https://www.learningcontainer.com/wp-content/uploads/2020/05/sample-mp4-file.mp4')
]
)
The code above sends two videos (first from the Instagram) to the user. After I send a command calling this code to my bot I get following error: telegram.error.BadRequest: Wrong file identifier/http url specified. What am I doing wrong?
If I use the second url instead of the first one everything works fine, the problem arises only when using Instagram's urls for the videos (photos with InputMediaPhoto works fine).
Also I can send the Instagram video separately, just by calling sendVideo method with the Instagram's video link in the input, but I am trying to send a batch of videos or photos in this bot.
I was wondering if it was possible to gain your other channel-IDs, this code under is only getting one channelID (the one channel i clicked on during the authorization).
def gaining_channelID(youtube):
channels_list_response = youtube.channels().list(
part="id",
mine=True
).execute()
channelid= ""
for list in channels_list_response["items"]:
channelid= list["id"]
print(channelid)
return channelid
And can i upload videos to your other channels? Or do i HAVE to go through the the authorization again and choose a different channel i want to upload to?
right now it seems like that's the only way
ive been watching this and it said so, but was wondering if it had changed (since that was 2 years ago the question was asked)
YouTube API v3 get all channels associated with a logged in user
When you authenticate to the YouTube API you pick a channel. In my case I have 6 channels I think. If I authenticate to the first channel I will only have access to the first channels data.
Yes you need to authenticate for each of the channels. The access you get will be channel specific.