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.
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...
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.
I have searched for this issue, for at least one week and I did not find something helpful.
The question is that I want to grab a frame from a video uploaded using C#. I used some APIs but they only grab frame from avi, mpeg and mpg files but when the client uploads an m4v, 3gp, mov, m2v or mp4 file, the respective APIs found on the web do not support retrieving the frames from these types of videos.
Am I missing something or is there an API that can handle retrieving frames from all types of videos in C#.
Thanks in advance
Solutions to this will vary per video encoding type. You will be hard-pressed to find one system to support them all.
You might consider executing a call to ffmpeg to generate the output you desire as it supports a very large variety of formats. See this question for a few .NET-based ffmpeg wrappers that may be helpful.
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 !
I am uploading documents on Google Docs as:
DocumentsService myService = new DocumentsService("");
myService.setUserCredentials("username#domain.com", password );
DocumentEntry newEntry = myService.UploadDocument(#"C:\Sample.txt", "Sample.txt");
But when I try to upload a file of 3 MB I get an exception:
An unhandled exception of type
'Google.GData.Client.GDataRequestException'
occurred in Google.GData.Client.dll
Additional information: Execution of
request failed:
http://docs.google.com/feeds/documents/private/full
How can I upload large files to Google Docs?
I am using Google API ver 2.
In your code you are attempting to upload a .txt file.
This will be converted to a Google Docs "Document" file.
Files that can be converted are limited to 1 Million characters of (2Mb in size).
If you change the extension type to something that is not recognised by Google Docs (for example .log), it will allow you to upload a file of up to 10Gb! Although the free account only has 1Gb of storage for files.
This will allow you to store and retrieve files via your application, but the user will not be able to directly modify them with the Google docs interface, although they can still download it.
There is a limit on size of file being uploaded:
http://docs.google.com/support/bin/answer.py?hl=en&answer=37603
Note that there is a conversion done to html and that post-conversion size id the limit.
If you could post some more specifics I could probably come up with a creative solution. What comes to mind so far are:
How about break document up into smaller documents and link then in either file name or actual link in document.
Pre process the document into streamlined text (not sure what kind of files you need to upload.
Upload as stored files and maybe have a google doc that loads the content in an iframe or something similar.
But yeah, if you give me more details, I can think it out if you like.
Try to findout terms and conditions, if they support larger files. Also there will be timeouts set in the library, see ifyou can increase your timeout values in your GData.Client
You have a file limit of 500Kb for documents to be converted.
http://docs.google.com/support/bin/answer.py?hl=en&answer=37603