ffmpeg convert mov file to mp4 for HTML5 video tag IE9

后端 未结 6 457
心在旅途
心在旅途 2020-12-12 09:41

I looked everywhere here and on google - there is no valid command that works for IE9. some how IE9 is missing something. All that I tried worked everywhere else: chrome,saf

相关标签:
6条回答
  • 2020-12-12 09:54

    I spent many hours trying to figure that one out. I finally found how to do this properly using avconv (or ffmpeg)

    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. 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-12-12 10:03

    A Primary journey to ffmpeg


    Download latest ffmpeg and its presets http://www.ffmpeg.org/download.html

    Follow the instructions to install Ffmpeg Binary In Windows


    Instructions:

    1. Get the latest build from the arrozcru autobuilds page
    2. Unzip the folder into C:/Program Files/ffmpeg
    3. Add C:/Program Files/ffmpeg/bin to your system’s PATH environment variable

    Optional libx264 preset setup:

    If you use libx264 presets (by using the -vpre flag) you need to do the following setup.

    1. Create a HOME environment variable for your user pointing to your home directory. (e.g. for Vista/7/8 C:/Users/moose or for XP C:/Documents and Settings/moose )
    2. Create a .ffmpeg folder in your home directory
    3. Copy the preset files from C:/Program Files/ffmpeg/share/*.ffpreset into %HOME%/.ffmpeg
    4. Now you can open a command prompt and use ffmpeg. :D (e.g. This is my Vimeo video conversion command. ffmpeg -i input.mov -vcodec libx264 -vpre hq -crf 24 -g 25 -acodec libmp3lame -ab 192k -ar 44100 output.mp4 )
      *NOTE: libfaac is not included in the build since libfaac is considered to be a non-free plugin

    Remember to set the HOME environmental variable in windows

    1. Copy the presets under the environmental variable folder
    2. You need to use the following commands to convert using ffmpeg:

    For mp4 (H.264 / ACC):

    ffmpeg -i INPUTFILE -b 1500k -vcodec libx264 -vpre slow -vpre baseline -g 30 "OUTPUTFILE.mp4"
    

    For webm (VP8 / Vorbis):

    ffmpeg -i "INPUTFILE"  -b 1500k -vcodec libvpx -acodec libvorbis -ab 160000 -f webm -g 30 "OUTPUTFILE.webm"
    

    For ogv (Theora / Vorbis):

    ffmpeg -i "INPUTFILE" -b 1500k -vcodec libtheora -acodec libvorbis -ab 160000 -g 30 "OUTPUTFILE.ogv"
    
    0 讨论(0)
  • 2020-12-12 10:06

    For ffmpeg:

    ffmpeg -i {input}.mov -vcodec h264 -acodec aac -strict -2 {output}.mp4
    

    You may also add the -q:v/-q:a parameter to specify the quality of the video. You may also use HandBrake which is a simpler encoder than ffmpeg.

    For HandBrake:

    handbrakecli -i {input}.mov -e x264 -E facc -o {output}.mp4
    

     

    EDIT: I found the solution! Here is a ZIP with a working demo that I tested on IE 9 and Firefox!

    http://www.mediafire.com/download/kyavlpudybg0bc1/HTML5_video.zip

    Also, the above demo has a flash fallback, so it should work on IE8 and less.

    Same ffmpeg command used.
    EDIT: I had to re-upload the video, since my hosting service is down for now. Now it is hosted on mediafire. I found they are the best file sharing service. Minimum ads, no registration, no 30 sec wait.

     

    Also, check out this discussion on the videojs website: http://help.videojs.com/discussions/problems/1020-ffmpeg-command-produce-your-demonstration-video.

    VERY IMPORTANT! Make sure to click the 'Allow Active Content' button to allow the video when running locally!

    Video of the problem I have and my solution: See my demo mentioned above.

    HTML code used while testing:

    <!DOCTYPE html>
    <html>
    <body>
    
    <video width="320" height="240" controls>
      <source src="movie.mp4" type="video/mp4">
      <source src="movie.ogg" type="video/ogg">
      Your browser does not support the video tag.
    </video>
    
    </body>
    </html>
    

    I analyzed a working test video that w3schools provides (it works on IE), and I found out that they used HandBrake to encode the video.

    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'movie.mp4':
      Metadata:
        major_brand     : mp42
        minor_version   : 0
        compatible_brands: mp42isomavc1
        creation_time   : 2010-05-11 10:32:06
        encoder         : HandBrake 0.9.4 2009112300
      Duration: 00:00:12.61, start: 0.000000, bitrate: 202 kb/s
        Chapter #0.0: start 0.000000, end 12.612000
        Metadata:
          title           :
        Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 320x240, 80 kb/s, 29.65 fps, 29.97 tbr, 90k tbn, 59.31 tbc
        Metadata:
          creation_time   : 2010-05-11 10:32:06
        Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 115 kb/s
        Metadata:
          creation_time   : 2010-05-11 10:32:06
        Stream #0:2(und): Subtitle: mov_text (text / 0x74786574)
        Metadata:
          creation_time   : 2010-05-11 10:32:06`
    
    0 讨论(0)
  • 2020-12-12 10:07

    My issue was the pixel formatting.

    Adding -pix_fmt yuv420p fixed it in IE for me.

    0 讨论(0)
  • 2020-12-12 10:08

    Had the same problem a while ago, and i successfully resolved in this way:

    First , download the latest version of ffmpeg (or build from the official github repository (https://github.com/FFmpeg/FFmpeg ), if you want to make some experimentation).

    Then try this:

    ffmpeg -i input.mov -c:v libx264 -c:a libfaac -strict experimental output.mp4
    

    Hope this will help out!

    0 讨论(0)
  • 2020-12-12 10:12

    from orig link...

    WebM is fully supported in ffmpeg 0.6 and later. On the command line, run ffmpeg with no parameters and verify that it was compiled with VP8 support:

    you@localhost$ ffmpeg
    FFmpeg version SVN-r23197, Copyright (c) 2000-2010 the FFmpeg developers
    built on May 19 2010 22:32:20 with gcc 4.4.3
    configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc 
    --enable-pthreads --enable-libfaac --enable-libfaad --enable-libmp3lame 
    --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora 
    --enable-libx264 --enable-libxvid --enable-x11grab --enable-libvorbis 
    --enable-libvpx
    

    If you don’t see the magic words “--enable-libvorbis” and “--enable-libvpx” you don’t have the right version of ffmpeg. (If you compiled ffmpeg yourself, check to see if you have two versions installed. That’s fine, they won’t conflict with each other. You’ll just need to use the full path of the VP8-enabled version of ffmpeg.)

    I’m going to do a two-pass encode. Pass 1 just scans through the input video file (-i pr6.dv) and writes out some statistics to a log file (which will be auto-named pr6.dv-0.log). I specify the video codec with the -vcodec parameter:

    you@localhost$ ffmpeg -pass 1 -passlogfile pr6.dv -threads 16  -keyint_min 0 -g 250 -skip_threshold 0 -qmin 1 -qmax 51 -i pr6.dv -vcodec libvpx -b 614400 -s 320x240 -aspect 4:3 -an -y NUL
    

    Most of the ffmpeg command line has nothing to do with VP8 or WebM. libvpx does support a number of VP8-specific options that you can pass to ffmpeg, but I don’t yet know how any of them work. Once I find a good explanation of them, I’ll link it here and incorporate them into the narrative if it’s worthwhile to do so.

    For the second pass, ffmpeg will read the statistics it wrote during the first pass and actually do the encoding of the video and the audio. It will write out a .webm file.

    you@localhost$ ffmpeg -pass 2 -passlogfile pr6.dv -threads 16  -keyint_min 0 -g 250 -skip_threshold 0 -qmin 1 -qmax 51 -i pr6.dv -vcodec libvpx -b 614400 -s 320x240 -aspect 4:3 -acodec libvorbis -y pr6.webm
    

    There are five important parameters here:

    • -vcodec libvpx specifies that we’re encoding with the VP8 video codec. WebM always uses VP8 video.
    • -b 614400 specifies the bitrate. Unlike other formats, libvpx expects the bitrate in actual bits, not kilobits. If you want a 600 kbps video, multiply 600 by 1024 to get 614400.
    • -s 320x240 specifies the target size, width by height.
    • -aspect 4:3 specifies the aspect ratio of the video. Standard definition video is usually 4:3, but most high-definition video is 16:9 or 16:10. In my testing, I found that I had to specify this explicitly on the command line, instead of relying on ffmpeg to autodetect it.
    • -acodec libvorbis specifies that we’re encoding with the Vorbis audio codec. WebM always uses Vorbis audio.
    0 讨论(0)
提交回复
热议问题