61

Despite all the hype, in reality the HTML5 video tag has a bit of a problem. In order to use it and for it to be cross browser compatible, you have to include more than one format of the video. To target all supported browsers these formats are mp4 and ogg.

I was searching around for optimum settings for each format but unfortunately I couldn't find any. I'm using ffmpeg 0.6 which has the tagline "Works with HTML5". I'm no video expert so I was wondering if anyone could recommend decent settings for each format?

betamax
  • 13,431
  • 9
  • 38
  • 55
  • 45
    "Questions are expected to generally relate to programming or software development"... **So what's this, a dating question?:** `"ffmpeg -i video_source_file.ext -vcodec libx264 -vpre slow -vpre ipod640 -b 250k -bt 50k -acodec libfaac -ab 56k -ac 2 -s 480x320 video_out_file.mp4"` – Roger Feb 24 '11 at 18:55
  • 1
    @Roger - This is more of an AV question than a programming question. Perhaps it should go on this stack exchange instead: http://avp.stackexchange.com – ArtOfWarfare Aug 20 '13 at 12:21
  • @ArtOfWarfare could it be migrated instead of closed please next time? thx – rogerdpack Aug 26 '13 at 17:38
  • @rogerdpack - I have nothing to do with this topic having been closed. I have insufficient rep to cast close/reopen votes... I think migrating a question between stack exchanges would involve contacting the actual paid employees of stack exchange. – ArtOfWarfare Aug 27 '13 at 12:39

1 Answers1

58

I ended up using ffmpeg and ffmpeg2theora.

WebKit compatible h.264 video

I decided to go for the ipod640 preset because it means the video can be viewed nicely on an iPhone or iPod touch. Of course, you can change the settings around a bit, get rid of the '-vpre ipod640', change the resolution or quality. Anyway the command is:

ffmpeg -i video_source_file.ext -vcodec libx264 -vpre ipod640 -b 250k -bt 50k -acodec libfaac -ab 56k -ac 2 -s 480x320 video_out_file.mp4

move some information to the front of the file so the video can play before it loads

qt-faststart video_out_file.mp4 video_out_file_quickstart.mp4

Firefox compatible Ogg video

This depends on you having ffmpeg2theora installed. Also, I have only tested it with the input file being the output file from the previous ffmpeg conversion. The command is:

ffmpeg2theora -o video_out_file.ogv video_out_file.mp4

Community
  • 1
  • 1
betamax
  • 13,431
  • 9
  • 38
  • 55
  • was this working for windows? when I try ffmpeg to convert to mp4 it throws an error like something is missing to convert to mp4 – Jake Mar 15 '12 at 15:04
  • I did not test it for Windows. It's more likely to work on OS X and Linux than Windows. – betamax Mar 15 '12 at 16:07
  • well ffmpeg works on windows cause I can convert to other codecs, but when trying to convert to mp4 it complains and I was wondering if their were additional settings required – Jake Mar 15 '12 at 16:09
  • 5
    I think that qt-faststart was moved into the main build of ffmpeg in the 1.0 release. You can now apply it with the flags: -movflags +faststart – baseten Feb 15 '13 at 12:37
  • 1
    Here's a helpful link for ffmpeg2theora on some basic parameters like video quality: http://en.flossmanuals.net/ogg-theora/encoding/ffmpeg2theora/ – manafire Nov 29 '13 at 15:25
  • +1 for webkit compatible specification! – Luca Davanzo May 28 '14 at 10:41