Reputation: 3568
I have a video encoded in MP4 as well as HLS (m3u8)format. I want VideoJS to use MP4 for desktops browser vs m3u8 for devices . The latest version of VideoJS supports both formats . I am trying to determine if videojs can automatically figure out which source to use. Or does my code have to detect browser and pass the best source type to videojs.
Upvotes: 7
Views: 9488
Reputation: 934
You can't provide both sources at once to any video player, leave alone VideoJS.
It's one or the other.
The source in your <video>
tag should either be a .mp4 (signed or straight-up).
Or it should be to a .m3u8 playlist.
You might have both available in your bucket/folder. But you can only provide one of them at a time as a source for a single player.
Upvotes: -1
Reputation: 25481
MP4 and HLS are actually different types of thing in the video delivery ecosystem.
MP4 is a container format, containing encoded video, audio etc tracks in a single file and HLS is a streaming protocol, which can stream a video in a container like MP4 from a server to a client.
The terminology can be a bit confusing and the terms are often not used precisely but a simple overview is:
The Streaming Protocol facilitates Adaptive Bit Rate streaming, ABR, which in simple terms means you provide multiple different bit rate versions of your video and the client device or player can download the video in chunks, e.g 10 second chunks, and select the next chunk from the bit rate most appropriate to the device and the current network conditions. See some more info in this answer also: https://stackoverflow.com/a/42365034/334402
In general, ABR protocols will give better performance so you would typically always select one rather than simply progressively downloading and playing the MP4 file itself when streaming your video.
It may be that you are concerned about some devices or browsers not supporting HLS. Most devices and HTML5 players probably will now but major video streaming services will usually provide HLS and MPEG-DASH streams for each video and this will cover the vast majority of devices.
Upvotes: 13