FFMPEG converted mp4 file does not play in firefox

2019-02-05 04:21发布

问题:

I have used FFMPEG command to convert flv video file to mp4 and use html5 video tag and play video in browser. But after the video is converted to mp4 using ffmpeg it does not play in firefox and chrome browser. It displays a error saying 'No video with supported format and MIME type found'. I have added the code below, Please help.

cmd /C ffmpeg -i INPUT_FILE_PATH -y -ar 22050 -ab 512 -b 800k -f mp4 -s 514*362 OUTPUT_FILE.mp4"

回答1:

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.



回答2:

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 .



回答3:

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 ]



回答4:

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!



回答5:

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



回答6:

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.



回答7:

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>