Is that possible to make <video> mirrored?

HtmlCssVideo

Html Problem Overview


Is that possible to make a video inside

Html Solutions


Solution 1 - Html

You can do it using a CSS3 3D transformation.

#videoElement
{
    transform: rotateY(180deg);
    -webkit-transform:rotateY(180deg); /* Safari and Chrome */
    -moz-transform:rotateY(180deg); /* Firefox */
}

This will rotate it 180 degrees around its Y axis (so you're now looking at it from behind) which gives the same appearance as being mirrored.

Example at http://jsfiddle.net/DuT9U/1/

Solution 2 - Html

You can use CSS3 scaleX or scaleY set to -1 to respectively flip the video horizontally or vertically.

Solution 3 - Html

Using JavaScript, if video is the video element, to mirror (flip horizontally) you can use

video.style.cssText = "-moz-transform: scale(-1, 1); \
-webkit-transform: scale(-1, 1); -o-transform: scale(-1, 1); \
transform: scale(-1, 1); filter: FlipH;";

To flip vertically you can use

video.style.cssText = "-moz-transform: scale(1, -1); \
-webkit-transform: scale(1, -1); -o-transform: scale(1, -1); \
transform: scale(1, -1); filter: FlipV;";

Solution 4 - Html

By any chance if somebody wants a working example, here is the code (with mirrored/rotated). Refer the video element #videoElement under style tag:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta content="stuff, to, help, search, engines, not" name="keywords">
<meta content="What this page is about." name="description">
<meta content="Display Webcam Stream" name="title">
<title>Display Webcam Stream</title>

<style>
#container {
    margin: 0px auto;
    width: 500px;
    height: 375px;
    border: 10px #333 solid;
}
#videoElement {
    width: 500px;
    height: 375px;
    background-color: #666;
    /*Mirror code starts*/
    transform: rotateY(180deg);
    -webkit-transform:rotateY(180deg); /* Safari and Chrome */
    -moz-transform:rotateY(180deg); /* Firefox */
    /*Mirror code ends*/
}

</style>
</head>

<body>
<div id="container">
    <video autoplay="true" id="videoElement">

    </video>
</div>
<script>
 var video = document.querySelector("#videoElement");

 navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia;

 if (navigator.getUserMedia) {
     navigator.getUserMedia({video: true}, handleVideo, videoError);
 }

 function handleVideo(stream) {
     video.src = window.URL.createObjectURL(stream);
 }

 function videoError(e) {
     // do something
}
</script>
</body>
</html>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSergei BasharovView Question on Stackoverflow
Solution 1 - HtmlPhonicUKView Answer on Stackoverflow
Solution 2 - HtmlCraig BlaggView Answer on Stackoverflow
Solution 3 - HtmlAndrewView Answer on Stackoverflow
Solution 4 - HtmlTechSinghView Answer on Stackoverflow