Im building an app to upload clips auto to a Minio S3 server.
When im playing and save a clip, the app uses 100% of bandwidth and this is so annoying.
I need to limit the upload speed to complete this, Thanks!
My upload string:
await s3.PutObjectAsync(bucketName, objectName, filePath, contentType);
You can't really do that with any built in functions, but one thing you could try is handling the transfer yourself at your own rate by writing a custom ThrottledStream.
That exercise will teach you how difficult what you want is to get right (for example, you can't just send X amount of data every second), so that's also a plus!
Related
i am a .Net developer who has written a CMS-System for the Intranet of a specific company.
Our client has the ability to upload videos and other media there and let his employees and customers view them alongside other information.
We use a Standard Httphandler to fetch the uploaded video from HDD of the server and context.response.TransmitFile() it to the Browser.
So we can use this Handler as target for a html5 src-Attribute.
Now i've gotten a request to sort of "emulate" a videostream. The idea is that the client uplaods the video as a file, sets a specific start date from which the video should be viewable and every Request to the video should then return only the slice from the video from startdate to now.
Sort of pretending this video would be a live stream which goes forward on its own.
I tried adapting the HttpHandler to calculate the number of seconds between the startdate and the current request time, multiply it by the bitrate of the video and then simply cut off x bytes from the Stream (for example using Stream.seek) but the resulting data does not get recognized by Brwosers as a valid video stream. I guess this is because of missing (cut away) header-informations and key-frames etc.
Does anybody know a library who allows me to do this (cutting the video in slices without writing them to harddisk, i dont want to have a videofile laying around for every request thats landed on my httphandler)
The video is in mp4 format and i would liek to avoid the additional overhead of having to transcode it (like VLC requires when you use it for streaming)
Any ideas on this topic, im kinda lost...!?
Thanks in advance.
Chris
Clarification:
I do not know how much to cut off the video beforehand, that depends on the moment the stream is requested.
The Formula is easy: Date of the Request (Datetime.Now) - Configured Start time of the video. This Timespan has to be "skipped" from the start of the video.
Ideally i woudl like some library which allows me to load the file as a fileStream, skip x Seconds and write the remaining bytes/frames to the output of the httphandler. But i have no idea how to do this as VLC and FFMPEG seem so only support slicing by writing files, not giving me the sliced data as a stream...
I'm looking to add a progress bar to a file upload to a WebService.
I just started working on a winforms application that I believe uses WCF to allow the client to upload a document to our corporate repository.
I'm using a UploadService where I pass it a Multi-part Stream consisting of metadata and a file. I've already taken care of building this part.
I'm not quite sure how to go about how to hook "something" to the stream so I can track it being uploaded
I've seen some people using a background worker to track the progress of a task asynchronously, but can't seem to find an example of someone doing this to track a file being uploaded to a WebService. I only seem to find an example of someone tracking the stream being built into memory.
Any advice/help is appreciated.
Thank you!
(I'm an intern, so if I mis-explained things, I apologize. I'd be happy to provide clearer details if necessary)
edit: From what I can tell the method to upload the stream only takes a stream in, there's no option to hand it the size of the stream, or how many bytes to read at a time.
Assuming you know the size of the file (if it's local you most likely do).
You're probably accessing it off-disk as a stream, and then copying it over to the upload stream.
If you're doing it in chunks (e.g a buffer), then you can calculate the progress:
var totalNumberOfChunks = (fileSize / chunkSize);
for(var chunk = 0; chunk < totalNumberOfChunks; chunk++)
{
// assuming you have the chunk byte array
// and have already sent it up to the server
var progress = ((double)chunk / totalNumberOfChunks) * 100;
// do something to surface this progress
}
Essentially you just want to work out how many separate chunks of data you're sending, and then as you send them calculate how far along you are and surface the progress somehow.
Of course, there are sometimes ways to have this done for you: Getting the upload progress during file upload using Webclient.Uploadfile
It´s simple. I have a page where the user can upload a video that will be stored in a directory inside the application.
But, as we know, the user can upload a 2mb video or 700mb video. What I need to do is convert the video while uploading or after upload (I don´t know which is the best way), in order to avoid large videos stored on the server.
I´m not sure but I think Youtube do the same thing.
OBS: I pretend to use the HTML5 video player.
Thanks very much for your reply! =)
As with all video questions, the answer is: It depends.
Some containers are designed for streaming (flv, mpeg-ts) and others are designed for random access (mp4, mkv). Some random access containers can be used for pseudo-streaming where the client can perform byte-range to performing random access over http.
If you have a user upload an flv, you can convert it as it streams up to you. If you have a user upload an mp4 with the moov atom at the end, you need to cache the entire file before you can do a conversion. if the moov atom is at the beginning, you can convert as it streams.
How to measure upload and download internet speed with silverlight and ASP.NET MVC between client and server.
How I think it's need to download/upload a file on the server.
Please help me with this problem
Thanks in advance
Sounds like you are trying to recreate SpeedTest.net. They use Flash, but the concepts should be roughly the same.
If you're referring to ASP.NET MVC because the Silverlight app is hosted on it, I'm not sure it will impact your design. This assumes that all the speed testing logic and UI is implemented in the Silverlight application.
Here's a good article from Laurent Bugnion on downloading files using WebClient:
http://www.galasoft.ch/mydotnet/articles/article-2008032301.html
That should give you all the information you need to download the file to the client, display a progress bar, and be notified when the download is complete. Using a fixed-size dummy data file, you can easily calculate the speed based on the size and time to download. The file should be fairly large but not too large, say 10 - 15Mb. That will ensure an accurate estimate of speed for both slow and very fast connections.
Uploading will work the same way in reverse. KrystalWare's SlickUpload component should have all the features you need.
The quick and dirty way to do it is just transfer a file to the client and have it send it back.
What you will need to do is have a file of known size, download it to the client, take the filesize/time to transfer and that is your download speed. Do the reverse process to get the upload speed.
It is a good idea to have a file at least a few MB in size so it can average out the peeks and valleys in the transfer.
You realize, of course, that the results of your test will be completely dependent on the internet connection that you are using to run the test. From what I am reading, your really just testing your internet connection, which you can do on various websites, such as www.speedtest.net.
Is there any way to easly know Transferrate between server/client during un filupload upload? Because uploading a file of 4,13Mb take about 5 or 6 minutes.... Is there anyway we can track it, by writing it in flatfile, email, response.write anything!! We're stuck.
Thanks to help us :(!
Not if you're using the built-in asp:FileUpload control. Some third party AJAX-based upload controls probably do this, but I don't know of any offhand.
Not easily.
HTTP works this way: you send ALL data and, after that, server begins to process your request.
But you can write some client code (flash, applet, silverlight) which break a file in pieces and send them, one at time, to server. This way you can compute your transfer rate.
Use a flash upload tool like SWFUpload, by which you can detect the upload speed, and then send the total time/speed to the server once the file is done.