17

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"
Vegard
  • 4,802
  • 1
  • 20
  • 30
stanley
  • 499
  • 4
  • 16
  • 29

7 Answers7

61

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.

Harry
  • 87,580
  • 25
  • 202
  • 214
LoneSpawn
  • 988
  • 1
  • 8
  • 8
  • While this works great and solved my initial problem too, if you're experiencing problems with a color cast or reduced contrast on the output video, try using `yuvj420p` instead of `yuv420p` – J Griffiths Feb 11 '16 at 01:37
  • Thanks to -pix_fmt yuv420p my mp4 is working in IE11/Firefox/Chrome/Edge now.I must check, what this is really doing, because this is the first place where I saw it – lkurylo Mar 10 '17 at 13:33
  • 1
    Be sure to also use the H.264 video codec (`-vcodec h264`) -- see other answers. – Bass May 27 '19 at 14:57
  • I have a similar issue where I only convert audio files to mp4/m4a and no audio gets played on Chrome or Firefox. https://stackoverflow.com/questions/64412488/convert-audio-to-audio-mp4-codecs-mp4a-40-2 – Stefan Falk Oct 18 '20 at 13:13
  • well, there is a Firefox 52.9.0 (32bit) that cant play this format neither :) – John Smith May 27 '23 at 21:47
3

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"
TylerH
  • 20,799
  • 66
  • 75
  • 101
AJ29
  • 1,381
  • 10
  • 10
  • This command I tried in my code below, but it still doesn't work in Firefox and chrome. I am merging 3 videos together and adding 1 extra audio channel and also overlaying two text layers over video. It plays audio in Firefox and chrome but video stays black. Any help? I am doing this in Android Application. Here is my code: https://www.dropbox.com/s/jvczuhkmlt76ykd/Androidcode.rtf?dl=0 – Tushar - iOS developer Mar 05 '21 at 14:34
  • How to boost the sound quality on this? – Ben G Jan 09 '23 at 05:08
3

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.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Ever Think
  • 683
  • 8
  • 22
2

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 ]

Community
  • 1
  • 1
Unrealist
  • 525
  • 4
  • 14
1

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

Edu Lomeli
  • 2,263
  • 20
  • 18
0

I have had similar problems - when combining png/mp3 from one collection, all went fine, but combining jpg/mp3 from another collection couldn't be played in browser but everything worked fine in vlc. I had already found that -pix_fmt was the issue and it worked when re-combining the png collection but not when re-combining the jpg collection, UNLESS using -vf scale as well.

-1

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.

Abhishek
  • 1,543
  • 3
  • 13
  • 29