Can't download from youtube encoding error - windows-phone-7

it's a week that I'm trying to write a program that download correctly from youtube
a video
the problem is this:
I've done via httpwebrequest a simple downloader and all work well.
I've tried download a mp4 video from a local server (uniform server) and all goes well, video is the same, work and is valid mp4.
When I download the same video from youtube something strange happens:
It fill some characters in downloaded file with sequence EF BF BD
for example when encounter character E2 (I've compared the two files one from youtube and the original). Googling around I discover that a server return this kinda sequence when encounterd a invalid char for your encoding, now I'm on wp7 and I can't set
Accept-Charset:
ISO-8859-1,utf-8;q=0.7,*;q=0.7
here's others useful data: I've try with these:
_webRequest.Method = "GET"; //also POST
_webRequest.UserAgent = #"Mozilla/5.0 (Windows; U; Windows NT 6.1; it; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16";
_webRequest.Accept = #"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
_webRequest.BeginGetResponse(_onDownload, userState);
format url from youtube
Any Idea?
thanks

Can you set the header using the _webRequest.Headers method? See these related questions:
Cannot set some HTTP headers when using System.Net.WebRequest
Constructing a POST in C#

Related

RecordRTC - Playing recordings on Safari fails

I am using RecordRTC to allow my application user to record their video and upload. This works perfectly fine with Chrome and Mozila Firefox but Safari having trouble playing recorded videos.
I research for the same and found mimeType: 'video/webm\;codecs=vp8' to be used for safari. However this still won't work on Safari browsers. (mac OS x and iOS)
Can someone please help me with this? I have multiple users working on different operating systems and working on different browsers and I want to make sure RecordRTC works for all of them.
I am open to change/ switch to any other alternative if available to implement this feature with cross-browser support of course.
I found Twilio but I am not sure whether Twilio supports standalone recordings or not? I mean I just want single user to go on a page record a video and upload.
Please see below my RecordRTC configuration if it helps:
const options = {
type: 'video',
mimeType: 'video/webm\;codecs=vp8',
bitsPerSecond: 128000,
timeSlice: 1000
};
After user completes the recording, I am converting it to a blob and append it to the formData to save it to the server:
var recordedBlob: Blob = recordRTC.getBlob();
formData.append('files', recordedBlob, this.courseComponent?.courseComponent?.name + '.webm');
This recorded video plays fine in Chrome and Firefox but in Safari it Fails.
Please if you can guide me through this it will be great help to me.
Thanks.
Below are the console log snaps:
1.browser does not support media recorder api
when tried to play the recorded video
says browser does not support media recorder api and try using whammyRecorder

serve video with go gin

I am writing a api server for upload and serve video and image by go-gin framework. I have uploaded my video to another host, and it worked
router := gin.Default()
//config := cors.DefaultConfig()
//config.AllowAllOrigins = true
routerConfig := cors.Config{
AllowAllOrigins: true,
AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"},
AllowHeaders: []string{"X-Requested-With", "Authorization", "Origin", "Content-Length", "Content-Type"},
AllowCredentials: false,
MaxAge: 12 * time.Hour,
}
router.Use(cors.New(routerConfig))
router.StaticFS("/public", http.Dir("static"))
err := router.Run(":5000")
if err != nil {
panic(err)
}
When I try to access http://localhost:5000/public/{image_url}.png by chromium. It loads to browser. But when I access http://localhost:5000/public/{video_url}.mp4 by chromium, it can't load anything from browser (It can't receive)
Can someone explain for me what I am doing wrong?
Update:
Maybe I missed this content:
Here are my 2 http packages when I call a GET request
There are 2 possible explanation for your problem.
It's not a problem because your browser doesn't have any feature to run video.
(This is more possible explanation) You don't set the correct header for streaming video so the browser can't recognize or don't know what to do with that URL.
For example I get from this video, when you check the Response Header, it should show
content-length: 1570024
content-range: bytes 0-1570023/1570024
content-type: video/mp4
My suggestion is use http.ServeFile which supports serving Range requests. See related questions, GoLang http webserver provide video (mp4) and How to serve http partial content with Go?.
Updated
After checking Gin StaticFS Godoc, I don't think it support Range header.
After Test
So I have try your code and I'm wrong, Gin StaticFS can serve content range like video.
Here my screenshot, have tested it using Chromium and it works well:
And my conclusions: There is a problem with your Chromium or your codecs or your video codecs not supported on your OS (I don't know what is your OS), check this MP4 not playing on Chrome version 27.0:
due to Chrome removing support for h264, on some machines, mp4 videos encoded with it will either not work (throwing an Parser error when viewing under Firebug/Network tab - consistent with issue submitted here), or crash the browser, depending upon the encoding settings
it isn't consistent - it entirely depends upon the codecs installed on the computer - while I didn't encounter this issue on my machine, we did have one in the office where the issue occurred (and thus we used this one for testing)
it might to do with Quicktime / divX settings (the machine in question had an older version of Quicktime than my native one - we didn't want to loose our testing pc though, so we didn't update it).

Setting contentType on AudioStreamer

I use the AudioPlayer to stream both mp3 and AAC Shoutcast streams on iOS, and in the main it works just fine. However to get AAC to work with a URL that does not end in .aac I had to hack the AudioStreamerCUR.m Objective-C code. I am not an Objective-C programmer and this was done very much on a trial and error basis. As there are number of url schemes used by Shoutcast and Icecast, my hacks are messy and it would be a lot easier to simply send the content-type along with the url like this:
var player = Titanium.Media.createAudioPlayer({
allowsAirPlay: true,
url: myURL,
contentType: "aac"
})
But I can't work out how to get a new property into the AudioPlayer proxy and then across to the actual AudioStreamerCUR.m - it seems some black magic is required. I wonder if there are any magicians who could point me in the right direction?
Thanks.
This is a property currently not exposed though the Titanium AudioPlayer API.
You might want to do a Feature Request Appcelerator JIRA. Check if it has already been requested before you create a new ticket. Refer to this question and also link back to the ticket here so that others can watch it with you.

How to get the client PC name?

In my project, I want to get the PC name of the client user
but the methods I am using just give me the PC name of the server:
System.get(user.name)
Sorry you can't directly
Your best bet is User-Agent header. You can get it like this in JSP or Servlet,
String userAgent = request.getHeader("User-Agent");
The header looks like this,
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.13) Gecko/2009073021 Firefox/3.0.13
It provides detailed information on browser. However, it's pretty much free format so it's very hard to decipher every single one. You just need to figure out which browsers you will support and write parser for each one. When you try to identify the version of browser, always check newer version first. For example, IE6 user-agent may contain IE5 for backward compatibility. If you check IE5 first, IE6 will be categorized as IE5 also.
You can get a full list of all user-agent values from this web site,
http://www.user-agents.org/
With User-Agent, you can tell the exact version of the browser. You can get a pretty good idea on OS but you may not be able to distinguish between different versions of the same OS, for example, Windows NT and 2000 may use same User-Agent.
Remember the scope the client could be behind a proxy
A smart idea is to use javascript and send infos via ajax call
Browser, Operating System, Screen Colors, Screen Resolution, Flash version, and Java Support should all be detectable from JavaScript (and maybe a few more). However, computer name is not possible across all browser at least.
You can do it with IE 'sometimes' as I have done this for an internal application on an intranet which is IE only. Try the following:
function GetComputerName()
{
try
{
var network = new ActiveXObject('WScript.Network');
// Show a pop up if it works
alert(network.computerName);
}
catch (e) { }
}

Streaming MP3 audio to HTML5 audio tag from servlet

I'm having some cross-browser compatibility joys. I have a Ruby WEBrick server with a couple of servlets, one of which is used to stream media (Ogg and MP3). The servlet gets a couple of query parameters (a base64 urlsafe string key, a small string user, and a small number, sid). When I put the URL verbatim into Chrome, I get the QuickTime extension, and it works. When I post the same into FireFox, I get the expected unsupported codec. When I put it in Safari, it works. However, the URL is not being accessed directly. I have a jQuery Mobile app that uses the Javascript Buzz library, and uses these servlet streaming URLs as sources. The code works in Safari, allowing me to play the sounds. On FireFox, instead of falling back onto Ogg, it gives unsupported errors, and on Chrome, it does nothing. Here's the code that serves the MP3:
res.status = 200
str = File.new("Music/#{req.query['sid']}.mp3", 'r:BINARY:BINARY').read
res.body = str
res['content-type'] = 'audio/mpeg'
Can anyone tell me how to get audio streaming to all browsers through a Ruby servlet?
Note: This is not a duplicate. I've been thorough a lot of SO answers, but none work because they are designed for static files, not servlets.

Resources