FFMPEG converted mp4 file does not play in firefox and chrome

♀尐吖头ヾ 提交于 2019-11-30 04:13:42
LoneSpawn

This is what you need. I recently found myself fighting the same problem.

Add this to your command:

-pix_fmt yuv420p

If you don't specify the pix_fmt it defaults to yuv444p which doesn't seem to be compatible with current browsers.

The full command I'm successfully testing with is:

ffmpeg -y -i "INPUT-FILE" -c:v libx264 -preset slow -crf 22 -pix_fmt yuv420p -c:a libvo_aacenc -b:a 128k "OUTPUT-FILE"

Put your input, output paths inside the quotes and try that to get started. Plays in current IE, Firefox, and Chrome. I'm using the built in aac encoder for audio.

Are you using latest version of Firefox and Chrome. ?

Do you installed necessary codecs on your system and browsers ?

Older version browsers will have problems of displaying multimedia or MIME contents.. Also improper or old codecs will cause problems .

Unrealist

I think the issue with your encoding is not FFMPEG or HTML5. It's in the command and libraries that you are using. You should use the "libx264" library to encode MP4 videos for HTML5.

The proper command to use should be.

ffmpeg -i input.mov \
-acodec libfaac -ab 96k \
-vcodec libx264 -vpre slower -vpre main \
-level 21 -refs 2 -b 345k -bt 345k \
-threads 0 -s 640x360 output.mp4

For copy-paste convenience

ffmpeg -i input.mov -acodec libfaac -ab 96k -vcodec libx264 -vpre slower -vpre main -level 21 -refs 2 -b 345k -bt 345k -threads 0 -s 640x360 output.mp4

If you happen to stumble upon missing the x264 codecs, you may install the Zeranoe builds. Refer to this SO page. [ FFmpeg installation for x264 codec ]

More encoding instructions can be found in [ https://trac.ffmpeg.org/wiki/x264EncodingGuide ]

Based on the answer of @Unrealist it seems it is a problem of video codec compatibility. You need to check browsers video format support, and then select appropiate audio and video codec in FFMPEG:

HTML5 video codecs browsers support chart

The changes I've made to your command line:

  • I've specified the audio codec explicitely so it is AAC-LC.
  • The addition of "-strict -2" to use the experimental AAC-LC codec.

This works for me in both Firefox and in Chrome.

ffmpeg -y -i "INPUT" -ar 22050 -ab 512 -b 800k -f mp4 -s 514*362 -strict -2 -c:a aac "OUTPUT.mp4"

I hope that helps, if so please mark this as good answer!

Check for MIMe type support added to your server, that is the problem in your case as error displaying there ' It displays a error saying 'No video with supported format and MIME type found'. As for your info there is no support for MP4 MIME type added in IIS 7 which you have to add by changing its web.config file in the given way..

<configuration>
   <system.webServer>
      <staticContent>
         <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
      </staticContent>
   </system.webServer>
</configuration>

hope this will give insight in your problem.

I think this is way off the answer you are looking for, but you really need to try Miro Video Converter.

I've used it in several projects and the video works great on Firefox, Opera, Chrome, Internet Explorer. And also works on mobile devices.

A beautiful, simple way to convert almost any video to MP4, WebM (vp8), Ogg Theora, or for Android, iPhone, and iPad. Batch conversion, custom sizing, and more!

100% Free and open-source.

Combine it with video.js and your done!

This is the HTML I use for it:

<video id="video" class="video-js vjs-default-skin" width="960" height="540">
    <source src="http://www.domain.com/video.mp4" type='video/mp4' />
    <source src="http://www.domain.com/video.webm" type='video/webm' />
    <source src="http://www.domain.com/video.ogv" type='video/ogg' />
</video>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!