Best way to convert a video while uploading - ASP.NET C# - c#

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.

Related

How can I save a webcam-recorded mp4 with audio in Visual C#?

I'm two days into researching this so I thought I'd post here. It looks like video recording software is usually written in C++ but my project requires C#. It's a WPF application and I just need it to save an mp4 locally. I don't need to upload to a server, I don't need to let the user pick a file location, I don't even need it to display the webcam feed as it's recording. All I need it to do is start/stop recording audio and video from a webcam/microphone and save it in a location that's determined by the code. I understand this may be broken down into steps like connecting to a webcam, connecting to a microphone, synchronizing them, encoding a video file, and saving it on the hard drive.
Are there any .NET classes that can help me with this? If not, can anyone recommend some libraries/frameworks/etc. that handle this sort of thing? I appreciate any help regarding how to do this. Thank you.

How to download a video file from YouTube to hard disk using C#.NET?

How to download a video file from YouTube as .FLV or .MP4 format to hard disk using .NET?
I want to create a small YouTube downloader application which asks the user for the specefic link, when i click the download button, the download process start downloading the video as an FLV file directly from YouTube server to the hard disk.
I'm not asking here for the detailed procedure but i want to know only how to start ? is there a YouTube c# api which handle this process.
How to download an Flv video file from YouTube to hard disk using C# ?
Thank you !
I think this project is interesting
https://github.com/flagbug/YoutubeExtractor
try run an embed browser and add event handler to grep URLs of all resources on webpage, then you can study the protocol used by youtube.
changing the HTML request header to simulate an iOS device may force youtube use HTML5 player , instead of flash player ( if the above method cannot track network activities inside a flash player )
Find an open source program that can do this, and read the portion of the source code that forms the youtube requests.
For example, gPodder is my favorite application of this type, and would be a good choice if you read python code. But I'm sure you can find others.
Once you find out the right format for requests, you can use C#'s HTTP classes such as HttpWebRequest. Finally, save the data to a file.
Google has also provided some documentation for accessing YouTube from .NET, but this is more related to the social networking aspects of the site than the video content.

Limit the length of a video uploaded to YouTube via C#

I'm working on a project that will use the .NET wrapper for the YouTube API. We will provide a form to users where they can upload a video and it will get posted to a specific page on YouTube. We'd like to limit the length of videos that are uploaded to 60 seconds. Is it possible to set such a length limit at the C#-level in the upload code? I was unable to find anything specific about this in the API docs.
I suspect that this cannot be done as you need to upload the actual video first to determine its length.
You will have to resort to saving the file locally on the server before transmitting it to YouTube. You would then have to use a Media Library to load the video and confirm its length before doing any further processing.
See this for an example.
I haven't used the YouTube API, but an alternative may be to upload the video, check its legnth from YouTube and remove it if it is in violation of your limits.
You are correct. You would have to upload and then check the file attributes to determine length. Theoretically, you can query this while streaming, as you can look at the metadata in the header. I have never queried video, so I am not sure how this is formatted. If you head this direction, you can abort the stream if the header has a length attribute greater than 60 seconds.
A possible issue here is certain types of media files don't contain the length attribute. I am not sure about the types one can upload to YouTube, however.

Convert Isolated Storage /RAW Format into WMV on Client side

Currently we're trying to create a project which has access via web cam to capture
the Video and Audio and store it on Cache.
We have been able to successfully capture the Video into the "Isolated Storage" or "Raw" File format. The next step is to create a silverlight friendly format like WMV version 8 or 9 which can be used for Replay.
Asof now we have been able to successfully get a project from Link
to capture the video and encode it into AVI format for replay mode. Unfortunately we've not been able to get a client version code snippet or API that allows encoding into WMV format directly.
Any pointers in the direction would be most appreciated.
TIA
For the moment there is no easy solution for encoding video/audio raw format from SL, and I think SL5 does not have that capabilities as well.
The only solution I found when I had that question too, was from StreamCoders's SilverSuite product, but it was too pricey for my needs. You might have a look there:
http://www.streamcoders.com/products/silversuite.html
Another solution would be to upload the raw data to a server and perform the encoding there, problem is the size of the raw data file are so big that it make it even not suitable.
I tried to zip the raw file, for a 45 second video/audio I had ~ 320 MB file size and ~ 210 after zipping. That was still way too high for my need.
So far I've not see much hope encoding raw file from the client side apart from the StreamCoders products.
Good luck
We have been developing the same application as a Pure Silverlight Browser solution and moved towards an out of browser solution where -
We capture the RAW Isolated Storage Format and convert it into AVI using AVIDLL available from the following urls -
Silverlight 4 More on Capturing Videos from Webcams
Silverlight 4 Yet More on Capturing Videos from Webcams
And later convert the AVI video (RAW->AVI) which is still large into a WMV file using FFMpeg.exe
Statistics on SIZE:
RAW atleast 700MB for a 1 min recording
AVI atleast 600MB after conversion from RAW
WMV atleast 500KB after conversion from AVI
Statistics on TIMELINE:
RAW to AVI conversion takes about 1min for the 700MB conversion
AVI to WMV conversion takes another 1min for the 600MB conversion
Comparing this with the RAW file upload to the server and converting it would be quite a time consuming process considering that the RAW file size is large.
Any optimizations which could help change the time taken to convert or perform a direct conversion to WMV could make the solution better.
Cheers !

How to grab thumbnail every X seconds from *live* Windows Media Stream

I want to provide a choice between streaming 'channels', if you will, in a web application. These are Windows Media streams of live events that are being broadcast from a Windows Media Services 9 distribution network.
I want to provide a relatively recent thumbnail image of the stream (as a user, you would expect to see this), but although I've seen this done in Flash on CNN and countless other sites, I've never seen this done with Windows Media.
I already have a C# / DirectX library that can extract a thumbnail from a WMV file, but obviously the stream doesn't come from a file if it's a live source.
My assumptions so far are:
Will need to run some kind of service application/daemon that will receive a stream into a Windows Media Player object and somehow take thumbnails if WMPlayer supports it...
-or-
Configure the streams to archive to file, and use the existing class library to take a peek at the last frame available in the archive file being written to get the thumbnail.
I would much rather do #1 because it seems like the clean solution, but don't know if/how WMPlayer supports grabbing a frame.
Are there better ways of doing this?
Not sure if using media player is a good idea in such case. I would look into this:
http://sourceforge.net/projects/windowsmedianet/

Categories