HTML5 - mp4 video does not play in IE9

前端 未结 13 1922
一生所求
一生所求 2020-11-27 05:08

I have an mp4 video that I want to play in IE9 using HTML5 tag. I added the MIME type to IIS 7 so if I browse http://localhost/video.mp4

相关标签:
13条回答
  • 2020-11-27 05:41

    Internet Explorer and Edge do not support some MP4 formats that Chrome does. You can use ffprobe to see the exact MP4 format. In my case I have these two videos:

    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'a.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf56.40.101
      Duration: 00:00:12.10, start: 0.000000, bitrate: 287 kb/s
        Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p, 1000x1000 [SAR 1:1 DAR 1:1], 281 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
        Metadata:
          handler_name    : VideoHandler
    
    
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'b.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf57.66.102
      Duration: 00:00:33.83, start: 0.000000, bitrate: 505 kb/s
        Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1280x680, 504 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
        Metadata:
          handler_name    : VideoHandler
    

    Both play fine in Chrome, but the first one fails in IE and Edge. The problem is that IE and Edge don't support yuv444. You can convert to a shittier colourspace like this:

    ffmpeg -i input.mp4 -pix_fmt yuv420p output.mp4
    
    0 讨论(0)
  • 2020-11-27 05:42

    If any of these answers above don't work, and you're on an apache server, adding the following to your .htaccess file:

    //most of the common formats, add any that apply
    AddType video/mp4 .mp4 
    AddType audio/mp4 .m4a
    AddType video/mp4 .m4v
    AddType video/ogg .ogv 
    AddType video/ogg .ogg
    AddType video/webm .webm
    

    I had a similar problem and adding this solved all my playback issues.

    0 讨论(0)
  • 2020-11-27 05:44

    Ended up using http://videojs.com/ to support all browsers.

    But to get the video working in IE9 and Chrome I just added html5 doc type and used mp4:

    <!DOCTYPE html>
    <html>
    <body>
      <video src="video.mp4" width="400" height="300" preload controls>
      </video>
    </body>
    </html>
    
    0 讨论(0)
  • 2020-11-27 05:44

    Internet Explorer 9 support MPEG4 using H.264 codec. But it also required that the file can start to play as soon as it starts downloading.

    Here are the very basic steps on how to make a MPEG file that works in IE9 (using avconv on Ubuntu). I spent many hours to figure that out, so I hope that it can help someone else.

    1. Convert the video to MPEG4 using H.264 codec. You don't need anything fancy, just let avconv do the job for you:

      avconv -i video.mp4 -vcodec libx264 pre_out.mp4
      
    2. This video will works on all browsers that support MPEG4, except IE9. To add support for IE9, you have to move the file info to the file header, so the browser can start playing it as soon as it starts to download it. THIS IS THE KEY FOR IE9!!!

      qt-faststart pre_out.mp4 out.mp4
      

    qt-faststart is a Quicktime utilities that also support H.264/ACC file format. It is part of libav-tools package.

    0 讨论(0)
  • 2020-11-27 05:44

    use both format it works fine in all browser:

    <video width="640" height="360" controls>
        <!-- MP4 must be first for iPad! -->
        <source src="unbelievable.mp4" type="video/mp4" /><!-- Safari / iOS video    -->
        <source src="movie.ogg" type="video/ogg" /><!-- Firefox / Opera / Chrome10 -->
    </video>
    
    0 讨论(0)
  • 2020-11-27 05:44

    Whithout JavaScript, the only way I could play without errors:

    <!--[if lte IE 9]>
    <!-- PUT HERE A FLASH PLAYER WITH video.flv -->
    <![endif]-->
    
    <!--[if gt IE 9]><!-->
    <video controls class="video">
        <source src="video.mp4" type="video/mp4">
        <!-- REPEAT FLASH PLAYER CODE HERE -->
    </video>
    <!--<![endif]-->
    
    0 讨论(0)
提交回复
热议问题