如何使视频具有相同的形状和高度 [英] How to make videos same shape and height

查看:75
本文介绍了如何使视频具有相同的形状和高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将两个视频上传到数据库中,并且正在我的网站上显示.我正在尝试使它们具有相同的形状和高度.宽度很好,但是其中一个形状像正方形,高度较长,而另一个则是矩形,高度较短,我知道这是因为视频拍摄的方式,一个是垂直拍摄的,另一个是水平拍摄的.如何使它们具有相同的形状和高度.你能帮我吗?

I have uploaded two videos to the database and Its being displayed on my website. I am trying to make them the same shape and height. The width is fine, but one of them is shaped like a square and the height is longer while the other is rectangle and the height is shorter and I know its because of the way video was taken, one was taken vertically and the other horizontally. How do I get them to be the same shape and height. Can you help me please?

     I tried this 

    <video class="video1" id="cb" preload="auto" video="src="{{$proo->video}}#t=1""   style=" height:80%; max-height:20em; width:100%; max-width:20em; object-fit: cover; 
 float:left; clear:both; 
     padding-left:2%;  margin-top:0px;     cursor:pointer; "><source="video1.jpg" playsinline alt="Video Unavailable"   id="" ></source>
  </video>

      this the javascript part to  handle the onclick,onmouseleave


  $(document).on('mouseover touchstart', 'video', function() { 
        $(this).get(0).play();
        this.muted=true;
    }); 



    //pause video on mouse leave
    $(document).on('mouseleave', 'video', function() { 

        this.currentTime = 1;
        $(this).get(0).pause(); 

    });

    $(document).on('click touchstart', 'video', function() { 
        $(this).get(0).play();
        this.muted=false;
        this.currentTime = 0;

    }); 

推荐答案

当我需要在iframe中输出YouTube视频时,我想到了这一点,它具有非常灵敏的含义,即可以根据当前情况调整其高度和宽度屏幕尺寸.

This a little something i came up with when i need to output YouTube videos in iframes and its very responsive meaning that it adjusts its height and width in relation with current screen size.

<style>
       #mediaPlayer{
        position: relative;
        height: auto;
        padding-bottom: 56.25%;
        padding-top: 1.875em; 
        overflow: hidden;
        border: 0.1875em double #185875; 
        background-image:url('../video_loading.gif'); 
        background-repeat: no-repeat;
        background-size: cover;
        -webkit-background-size: cover;
        -moz-background-size: cover;
        -o-background-size: cover;
        background-position: center;
        background-attachment: fixed;
       }

    #mediaPlayer iframe{
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        max-width: 100%;
        max-height: 100%;   
    }
</style>

/*use the div to specify the exact height and width you want*/ 

<div style="height: 50%; width:50%;">
 <center>
  <div id="mediaPlayer">
    <iframe id="play_now" width="100%" height="100%" src="source here" value="value here" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
  </div>
 </center>
</div>

对于那些网络速度较慢的用户,在加载iframe内容时,在背景中放置一些内容通常是一个好主意.

The video_loading.gif background is usually a good idea for users with slow network to have something in the background while your iframe content is loading

但是您必须找到自己的唯一gif文件/图像并将其设置在background-image:url('../file-location-here.gif');

but you have to find your own unique gif file/image and set it's location in the background-image:url('../file-location-here.gif');

这篇关于如何使视频具有相同的形状和高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆