<button id="capture" class="button">Capture</button>
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var capture = document.getElementById('capture');
capture.addEventListener('click', function(e) {
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
});
I expect to be able to draw the video frame to canvas, whether it's the native video player, or hls.js taking over
Canvas is empty. I believe Safari supports HLS, so is inserting the js player, but that is somehow preventing drawImage. I don't think it's CORS, because the same code/video works without HLS.js loading the source
If I flip the if statements it works because it uses mpegurl for safari:
if (el.canPlayType('application/vnd.apple.mpegurl')) {
// do something
} else if (Hls.isSupported()) {
// do something else
}
IE11 is also having issues with drawImage. The image displays but is squashed, even though the dimensions are reported correctly:
http://jsfiddle.net/kmturley/q8fqLdaj/47/
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Any resolution?
I came upon this thread while researching a similar problem.
Here is what my extensive testing has told me so far:
iOS Safari does not allow context.drawImage() to work on HLS video streams for some reason. However, it works fine on MP4.
IE11 does not support MediaSource which is what HLS.js uses IF you are on Windows 7. However, MediaSource is supported on Windows 8.1+ so HLS.js works on those.
IE11 does not support HLS natively.
Good luck!
This issue is not hls.js related but solely to browser impl of HTMLMediaElement and respective canvas image copy.
if (el.canPlayType('application/vnd.apple.mpegurl')) {
// do something
} else if (Hls.isSupported()) {
// do something else
}
this can really work!!
if (el.canPlayType('application/vnd.apple.mpegurl')) { // do something } else if (Hls.isSupported()) { // do something else }this can really work!!
It works fine on all desktop browsers I tested but I find the canPlayType("mimeType") is really 50/50 depending on the mobile device you're using.
Many mobile devices erroneously report "maybe" as a response which means it's unsure until you physically try to play it back. I've seen that sometimes, "maybe" does mean it can play while other times, it fails.
The response "maybe" is basically useless since it's not a deterministic answer.
Most helpful comment
I came upon this thread while researching a similar problem.
Here is what my extensive testing has told me so far:
iOS Safari does not allow context.drawImage() to work on HLS video streams for some reason. However, it works fine on MP4.
IE11 does not support MediaSource which is what HLS.js uses IF you are on Windows 7. However, MediaSource is supported on Windows 8.1+ so HLS.js works on those.
IE11 does not support HLS natively.
Good luck!