简体   繁体   English

上传视频时如何强制添加.mp4或.webm扩展名?

[英]How can I forcefully add .mp4 or .webm extension when uploading video?

How could I possibly add an extension of.mp4 or.webm?我怎么可能添加.mp4 或.webm 的扩展名? It only produces like this它只产生这样的

没有扩展的视频

HTML HTML

<input type="file" name="file[]" id="inpVid" accept="video/*">
<video style="width: 100%; max-width: 100%; margin-bottom: 10px;" controls id="vidURL">
  <source id="videoUrl" src="#" type="video/mp4">
</video>

SCRIPT脚本

<script>
    function changeVideoURL (element) {
      const videoURLElement = document.getElementById('videoUrl')
      const videoPlayer = document.getElementById('vidURL')
      if (element.files && element.files[0]) {
        videoURLElement.src = URL.createObjectURL(element.files[0]);
        videoPlayer.load()
      }      
    }
    document.getElementById("inpVid").onchange = function() {
      changeVideoURL(this)
    }
</script>

I think this is what you seek我想这就是你想要的

<input type="file[]" id="inpVid" accept="video/mp4,video/webm" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 上传时如何将视频转换为 mp4、webM、ogv? - How to convert video to mp4,webM,ogv while uploading ? 如何在Konva舞台上添加视频(.mp4,.mov)? - How would I add a video (.mp4, .mov) at Konva stage? 通过PHP fpassthru()加载mp4 / webm的Chrome HTML5视频:无法设置currentTime? - Chrome HTML5 video with mp4/webm loaded via PHP fpassthru(): can't set currentTime? 如何在 javascript 中获取自动播放的 html5 mp4 视频的当前时间,然后在时间达到 5 秒时停止它? - How can I get current time of autoplayed html5 mp4 video in javascript and then stop it when time reaches for lets say 5 seconds? JavaScript-将webm转换为mp4 - JavaScript - Convert webm to mp4 我可以使用 magnific-popup 来显示 MP4 视频吗? - Can I use magnific-popup to display an MP4 video? 如何将 Shaka Player 与通过 xhr 或 websocket 到达的原始 mp4 视频数据一起使用? - How can I use Shaka Player with raw mp4 video data arriving over xhr or websocket? 如何使用 node.js 下载视频 mp4 文件? - how can i download a video mp4 file using node.js? 在MVC中播放.mp4视频时如何停止滑块? - How to stop slider when .mp4 video is played in mvc? 如何将静音音频通道/AAC 编解码器添加到 Safari 的 MP4 文件? - How can I add silent audio channel/AAC codec to an MP4 file for Safari?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM