2

For days I have been struggeling with ffmpeg (PHP).

I have a website where users can upload video's. Obviously people use .mov, .mp4 and .mpeg created by various devices such as cameras, mobile telephones, tablets and many more devices. The problem I have is that those movies either work on Firefox or Chrome, but almost never on both. No clue why, I guess it has to do with codecs and browser support.

I am using FFMpeg to turn them into webm files. This works 95% of the time. In all browsers I have a working video and the sound works too. But sometimes there is no sound at all.

When I open the movie in a other browser (or Windows media player for example) I do hear sound. It is so random to in what browser or software it works or does not work.

Does anyone know of a way to make sure that your movies work in every browsers i.e. Chrome, FireFox and Safari with both video and audio? and if so, how can I transform them and into what format (codecs?)

I dont mind converting a movie into three different formats, as long as both video and audio works.

I hope someone can give me some advice. I have tried many ways but none work cross-browser so far.

An example of the code that I use:

$video->save(new FFMpeg\Format\Video\WebM(), 'export-webm.webm');

Does anyone know how I can make it work on every browser?

What I already tried is (amongst others):

using an original mp3 or mov and convert it into webm with this code:

ffmpeg -i origin.mov -c:a libvorbis -strict -2 -c:v libvpx-vp9 output.webm

Unfortunately in FireFox i have visual and audio but in Chrome I have nothing, just a blank screen.

1 Answers1

3

H.264 video with AAC audio in the MP4 container is probably your best bet.

ffmpeg -i input.mov -c:v libx264 -c:a aac output.mp4

H S
  • 45
  • 4
  • 1
    You should add output options `-vf format=yuv420p` for compatible chroma subsampling, and `-movflags +faststart` for fast start. – llogan Feb 12 '21 at 02:10
  • Some movies that I convert still have no sound on Google Chrome :( is there anyway to find out why this is happening? –  Feb 12 '21 at 15:26
  • I checked one of the video's that wont play sound in Google chrome. Video codec is AVC and audio codec is AAC LC it seems (checked with MediaInfo tool). –  Feb 12 '21 at 15:48
  • @Mithradantor Edit your question to include the complete output of `ffmpeg -i video-that-is-not-working.mp4`, or if that is not possible provide a link to `video-that-is-not-working.mp4` – llogan Feb 12 '21 at 19:24