Detect if a local video can be play in html5? - html

I'm trying to detect if a local file (or blob), that I don't know the type, can be play by the browser...
I can actually do this :
By using a setTimeout and onload, but we never now when the onload funtion will be fired...
By Using the file.type but it only uses the file name...
By using the readArrayBuffer, no way with big file...
Is there any way to detect if a file from the input file button can be play or not ?

You could do some sort of analysis of the file, mimicking the type of functionality that ffprove provides, and then compare the deduced video characteristics with a known map of video characteristics per browser type.
The file type, as you point out is only a crude guide - for example mp4 files may have many different 'characteristics' such as encoding format etc, some of which will be supported on some platforms and not on others.
However, this will be complex to implement and you will constantly have to update the mapping of video types support to browser types as this evolves over time.
The simplest and most reliable way is, as I think you are saying in your question, to try to play the video and then catch any errors generated.

Related

MPEG-DASH one file with audio+video

Is it possible to work mpeg-dash with only file and not two files, one for audio and one for video?
If so, please explain how to decode (tool, arguments).
Thanks in advance!
MPEG-DASH does not limit you to have separate audio/video tracks (two, or even more files). However, in many scenarios this is the preferable solution - think of multi-language use cases.
Regarding decoding/playback - that's highly depending on the used player and/or decoding engine. Most modern browser's Media Source Extensions are for instance capable of handling such multiplexed content.

Is it necessary to convert database of mp3's to ogg and wave to use html audio?

I have thousands of mp3 files in a database and a website that lets people listen to them. I'm using a flash player but want to move to html5 audio player. Does this mean that I need to make ogg and wave versions of all my audio files? What is a good approach to making these files more accessible?
In short, yes you need to support multiple formats. (Assuming you care about decent browser support.)
If you are lacking disk space, don't get a lot of traffic, and don't mind some delay before the data gets to the user, you can convert these on the fly. Just write some code so that on request, it checks the conversion cache to see if you have already converted the file. If not, convert it on the fly (with something like FFMPEG) and write the data to disk at the same time you are writing it to the client.
As Imre pointed out, browser support is changing all the time. Look up what codecs are supported from time to time.

Is it possible to convert an avi file to mp4 in real time?

I have an AVI file that I would like to be played inside Flowplayer. I understand it uses HTML5 which requires movie files to be converted to MP4/OGV, so I was wondering if there was a framework that exists which will convert an AVI file to an MP4 file in real-time (and without necessarily being stored on the server)
...the more I think about this, the more I'm beginning to think this isn't possible. Please prove me wrong.
The video can be transcoded in (sort of) realtime by hardware or even software, but I'ts never a practical aproach since you are spending lot of processing power for each client for each video. This is madness. It's adviceable to cache pages... so videos are needed to be cached.
A simple way is to upload/place the video in a folder in the server, then trigger a transcoding (using FFMPEG) to a file which is the file to be served.

Need to get video title of HTML5 <video>s and <audio>s

I'm trying to get video/audio metadata (in particular, the title) from HTML5 <video>'s and <audio>'s. I've not been able to find anything at all about it - am I correct that this is not possible through DOM manipulation/javascript?
If that's the case, I'm thinking I will have my server download the media file and look through the metadata to determine the title (if there is one). In that case, I'm using Node.js. Is there a good library in Node that I could use? I've tried the "fluent-ffmpeg" but it did not seem to be able to get data for most of the videos I'm using - perhaps they were using codecs that it did not understand.
Any ideas? Thanks :)
For this, you will typically have to get any metadata server-side. I don't know what language you're using, but TabLib can work well with many.
Metadata for streaming media is a whole separate issue, and is entirely dependent on the server hosting the media. For Icecast/SHOUTcast streams (and compatible), see Pulling Track Info From an Audio Stream Using PHP.
I would suggest using ffprobe for this, more specifically the node-ffprobe module. But yeah, you would need to download the file and parse it through your server, AFAIK the video and audio tags can't hold metadata information yet.

Crossbrowser media player

Is there any media player solution that will play audio and video files in Firefox,Chrome, Safari and IE.
I've tried MediaElementJS but it fails on .mov. This project has clients uploading a movie file and there can only be one version of each file. I can programatically change the code for each type of file and the user's OS/browser but I still couldnt get .mov's to download progressively.
What am I missing here? I'm not very familiar with media file types. Just wondering if anyone had any suggestions.
Take a look at the JW Player. It's highly configurable. Best combination is with a real streaming server provider. If you want to let your clients switch to different positions in your media files it might best work that you "normalize" all your different media types to one format (converting them after the upload) - be it .flv/flash - and focus on one player like the above. The files could be streamed with modules from webservers like nginx or lighttpd - but a real provider like Bits on the Run will convert most of the files for you very easily and handle the streaming more reliably.