Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play MP4 video in firefox

Tags:

I have a dynamic video path coming from database. Video can be uploaded in any format. When I load the video in Firefox, I see the following errors

Specified “type” attribute of “video/mp4” is not supported. Load of media resource path_to_video.mp4 failed.

I am loading the video in my html like

<p>  <video class="responsive-video" id="trailer">    <source src="<?php echo $biovideo?>" type="video/mp4">  </video> </p> 

Is there any way to play the mp4 videos in Firefox as I am not sure what extension the video will have

like image 456
baig772 Avatar asked Nov 23 '16 09:11

baig772


2 Answers

Update - Feb 2019

Firefox no longer uses GStreamer and instead interfaces directly with ffmpeg. Hence the flag mentioned below will no longer appear in current version of Firefox.

There is now a flag media.ffmpeg.enabled which again can be set to true:

  • go to Firefox about:config
  • search for the 'media.ffmpeg.enabled' flag
  • set it to true

In practice this is not necessary on many platforms - the latest official Firefox online notes say:

Patented media MP3, AAC, and H.264/MPEG-4 AVC are patented audio/video compression formats. They can be viewed in Firefox using built-in OS libraries (so neither Mozilla nor you need to pay a fee) if embedded in the MP4 container format (.mp4, .m4a, .m4p, .m4b, .m4r, .m4v file types).

To verify, a test as at February 2019:

  • With a clean install of Ubuntu 18.04, Firefox could not play a test mp4 stream. It can play video using other container standards, those with the following file extensions: webm and ogg
  • In the terminal ran 'sudo apt-get install ubuntu-restricted-extras' and accepted all licenses etc
  • With no other changes, i.e. no flag setting etc, Firefox can now play the test mp4 stream

Original answer - for older versions of Firefox

As noted in the comments Ubuntu/firefox does not support mp4 natively - this is due to licensing issues. The Mozilla documentation is a little confusing (IMHO) so the table at the bottom is probably the best place to look.

However you can add support fairly easily by installing Ubuntu extras:

sudo apt-get install ubuntu-restricted-extras

and then enabling gstreamer:

  • go to Firefox about:config
  • search for the 'media.gstreamer.enabled' flag
  • set it to enabled

This should allow you play the video.

like image 81
Mick Avatar answered Dec 05 '22 03:12

Mick


For ubuntu 20.04, run:

apt install libavcodec58

like image 32
IvanM Avatar answered Dec 05 '22 04:12

IvanM