Question

I am making an application in HTML5 that lets you choose a local video file, then play it using the video tag. The problem is that some of the codecs of the videos are not playable by current browsers (XviD in general, H.264 for Firefox, etc). Is it possible to locally convert the videos to the right codec using JavaScript?

Edit: I probably didn't explain myself correctly, I am making a kind of "Media Player" using HTML5: The user chooses a file, the script reads it using the HTML5 File API and then adds it to a video tag, no server involved. This is why I need JavaScript for this.

Was it helpful?

Solution

This would be a great deal of work, but you may want to look at the NaCl project, from Google, but it will still take a long time to do the conversion.

http://www.chromium.org/nativeclient/getting-started/getting-started-background-and-basics

Eventually this will be browser-independent, as they make plugins available, but at the moment this would only work on some versions of Chrome, I expect.

But, this way you can write your conversion in C so you can use other conversions tools already written.

You may want to explain which formats you can handle, and if they try to do one that isn't in that format, then suggest free tools to help do the conversion, to help them out.

OTHER TIPS

I don't believe you can easily do anything like what you want - especially if you expect users to select a video file and then within seconds it's being shared online.

There are a lot of variables and a ton of processing involved in video conversion/compression and there's a reason why even gigantic sites like YouTube take quite awhile to have your videos appear.

Plus, you want people to use a variety of video file types and somehow output the same type of video file, correct? Geez. Now you have to find open source video conversion apps that you can perhaps get to work behind the scenes just to get it to play nice with whatever you final video file type will be.

I don't see how this can be done with JavaScript alone. I think you could probably build an uploader and then maybe use another app to check a directory for new files and convert the files with a script to something else....but JS alone? And from your browser? And in a halfway decent amount of time? No way.

I would suggest only allowing certain types of video files to be uploaded and reject all others. Don't even mess with converting them.

I recently came across videoconverter.js but haven't had the time to try it out yet.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top