I have an HLS stream that expires every 12 hours and a new link is generated. How can I create one static HLS stream?
One idea I've thought of is to keep refreshing the stream and forwarding it to one static URL? Is this possible and could anyone point me to resources on how to do this?
One idea is, you can make a static link like M3U8 file which will be containing the link of your HLS streaming service.
Thereafter, you can update your M3U8 file every 12 hours as HLS streaming link get updated.
Therefore, the M3U8 file will be a static link forever.
A brief introduction is given here about M3U8 files.
Related
I want to know how to send image or media from a URL link,
file = BOT.upload_file('/user/home/photo.jpg')
BOT.send_file(chat , file)
I know that using this method we can send image from path, but I want to know if its possible to send it from a URL link. but I am trying to run the code on Heruku so uploading it from the patch will not be possible so if there is a way to send it using a URL link please tell me how to do that.
can anyone help me figure this out please.
you don't have to explicitly upload a file, telethon does it internally, so:
BOT.send_file(chat , '/user/home/photo.jpg')
is enough (unless you're willing to resend something pre-uploaded multiple times)
likewise, you can pass a URL to send_file, Telegram servers will fetch it and send by itself (note there are limits for file size, 5MB for images, 20 MB for documents)
BOT.send_file(chat , url)
I want to share some images (Local or stored in one drive, no issue) as a file attachment to MS Teams channel (not chat) using python.
I've already tried using Requests module and Webhooks to send Images (using base64 encoding and links), but they are the tiny images which can't be opened. I've also tried the Azure bot but it's only useful if we want to sent the image file to the chat.
If you do know, Can you share some sample working code (instead of sharing this link) here.
Technically, there is not proper chance to send images using python in teams. One of the previous researchers worked on this. As you are not focusing on bot and directly need to share the image using python. There is no procedure to accomplish the task.
https://techcommunity.microsoft.com/t5/microsoft-teams/post-image-to-teams-channel-from-local-path-using-python/m-p/2484798
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 write a simple kik bot to send videos from youtube.
Started with https://github.com/kikinteractive/kik-bot-python-example
Modified it this way:
messages_to_send.append(
VideoMessage(
to=message.from_user,
chat_id=message.chat_id,
video_url="https://www.youtube.com/watch?v=WHATEVER"
))
But when try, i get an error like:
kik.error.KikError: {"message":"Error sending video message:
text/html; charset=utf-8 is not a supported
Content-Type","error":"BadRequest"}
Dont know from where is taking "text/html; charset=utf-8" because i ve defined is a VideoMessage(
Sorry if it is a silly question, i am noob with kik and python
Thanks in advance
I think the video_url parameter expects an URL that points to a video file. In the example from their docs the URL is "http://example.kik.com/video.mp4", meaning (in my opinion) that it should be a video file. In your example, "https://www.youtube.com/watch?v=WHATEVER" would point to an HTML file (i.e. not a video file).
Maybe you'll have to find (a) if YouTube provides a URL that returns a video mimetype (I bet they don't), or (b) use something as youtube-dl to download the MP4 file, uplaod it somewhere else and use this somewhere-else's URL in yourt code snipet. Or… (c) just send a text message with the YouTube URL : )
Does that make sense?
I would like to know what is the most elegant way to scrape live webcam (traffic) data, ideally using Python. The webcam feed is represented by an API, with each get request yielding a image of the currently available feed from the webcam. The feed in question has a 2/3 second delay and therefore there are ~ 30 images per minute that can be requested.
My current (trivial) solution simply queries the API in a loop (perhaps with a sleep timer) and then cleans up any duplicated images. However, this seems quite dirty and I was wondering if there is a cleaner/more elegant solution available.
In principal I would like the solution to (if at all possible) avoid:
downloading duplicated images
sleep timers
looping
Is something like this possible?
To avoid sleep timers in your code, you can write a process that is triggered by cron. Cron will handle running your script at defined intervals, such as every 2 seconds (60s / 30 images per minute).
An example process might call the API using requests. Assuming an image is passed back, the following example code might work. If a JSON string is passed back then you will need to parse it and extract the image URL.
r = requests.get('https://traffic-cam-site.com/cam', auth=('user', 'pass'))
if r.status == 200:
image = r.content
To avoid downloading duplicate images, you would need to know when a new image is present on the API. You will need to periodically check the cam site API for this purpose. Store a hash of the collected images in a database (or text file), and send that with your request to the API. Then hash the image that is currently present on the cam site - if the hashes match, don't download the image to your server.
Alternatively, if the cam site API does push notifications then you may be notified when a new image is present.