MP4 fast-start woes

In order to play MP4 files while they are still downloading (either by for example Quicktime of Flash), in most cases you'll need to move the so called 'MOOV' atom to the beginning of the file.

The MOOV atom is in essence a block of data, containing an index of the rest of the file. Most authoring tools will place this data on the end of the file, because the size of the block will have to change dynamically as changes are made to the video. If the atom was right at the beginning, the entire file would have to be rewritten for a lot of smaller changes.

So, there are a couple of tools that do this for you, but none of them seem to work really well. FFMpeg contains a tool called 'qt-faststart', but I had to kill it after I discovered it had been running for 12 hours on a relatively small mp4 file.

Some suggestions on the FFMpeg mailing list led me to two other tools, MP4Box and MPEG4IP. MP4Box dies with a big:

  1. MP4Box /tmp/508842_22.mp4 -inter 500
  2. Saving /tmp/508842_22.mp4: 0.500 secs Interleaving
  3. *** glibc detected *** double free or corruption (!prev): 0x08071108 ***
  4. Aborted

On top of that their forum seems mostly dead. MPEG4IP simply has the following message on their download page:

NOTE: currently, the tarball is corrupt, and I do not have a way to remake it at this point. Hopefully that will change in a few weeks.

Dear lazyweb, has anyone else came across similar issues? How would one go about solving this? :(

Update: Reading through it again, it seems as if the mpeg4ip project has simply died in 2007.

Update 2: My problem with MP4Box was solved! I needed to explicitly supply the -out parameter.

FFMpeg to support Nellymoser within the month?

Seems like there might be a chance that FFmpeg will support the proprietary FLV Nellymoser codec within the month.

For those of you that don't know. Nellymoser is the codec used by the flashplayer and FMS to record audio from a users' microphone. Up until now the only place where you could ever replay these streams were in the flashplayer itself, locking you into the adobe jail.

FiTC 2007 presentation video

FITC presentation videos are online, including mine. Its the first time I actually watch it. It's a bit creepy to see myself, but I guess it went fine. I couldn't get a mic hooked up at the time, so the audio quality is a bit crappy.

I also notice that I made a bunch of mistakes related to embedding swf's, which I only found out later.

A funny fact: The girl sitting right in the front (and leaves after a while) is now my girlfriend. So we actually have video footage of when we first met :).

Presentation links

Update: added some of the source code used.

As promised, I'll put up some links from last nights presentation.. If you attended, I hope I got the message across, and if you're hungry for more, be sure to check out fitc, where I will do a 1 hour version of the presentation..

  • Flowplayer - FlowPlayer is an open source, skinnable, very powerful flash video player..
  • FFMpeg - To my opinion, the best tool out there to convert your video to flv.

    Binaries for OS/X are included in FFMpegX, binaries for windows can be found in Riva FLV encoder. Most Linux distributions also have a pre-compiled ffmpeg package..

    Remember though! Only use those for testing purposes, if you want support and support for for example WMV3, you really should compile your own..
  • SWFUpload - An open source library to leverage Flash 8's multi-file upload from javascript.
  • On2 Flix - An expensive, commercially backed FLV encoder.. If using the latest flash video codec is important to you, look at this product.

And there's even a small piece of the presentation recorded....

handling uploads..

Note that these scripts all assume an .mpg extension..

  1. <?php
  2.  
  3. foreach($_FILES as $file) {
  4.  
  5. $newFileName = 'uploads/original.mpg';
  6. move_uploaded_file($file['tmp_name'],$newFileName);
  7.  
  8. }
  9.  
  10. ?>

Simple conversion

  1. <?php
  2.  
  3. $ffmpegPath = '/Applications/ffmpegX.app/Contents/Resources/ffmpeg';
  4. $input = 'uploads/original.mpg';
  5. $output = 'uploads/converted.flv';
  6. $result = `$ffmpegPath -y -i $input -ar 44100 $output 2> /tmp/ffmpeg_log`;
  7.  
  8. ?>

Slightly more advanced..

Adjusts the bitrate, height and width, and also generates a thumbnail.

  1. <?php
  2.  
  3. $ffmpegPath = '/Applications/ffmpegX.app/Contents/Resources/ffmpeg';
  4. $input = 'uploads/original.mpg';
  5. $output = 'uploads/converted.flv';
  6.  
  7. $output = 'uploads/thumb.jpg';
  8. $result = `$ffmpegPath -y -i $input -an -s 320x240 -f mjpeg -ss 0:2:0 -t 0:0:0.001 $output 2> /tmp/ffmpeg_log`;
  9.  
  10. $output = 'uploads/converted.flv';
  11. $result = `$ffmpegPath -y -i $input -ar 44100 -b 320 -s 320x240 -ab 128 -acodec mp3 $output 2> /tmp/ffmpeg_log`;
  12.  
  13. ?>

Speaking at FlashinTO v59.0

FlashinTO I'll be speaking at toronto's flash user-group next gathering.

It's a bit scary, as this is my first presentation.. I'll be doing a short version (20 minutes) of my presentation at FiTC about uploading, converting and distributing video using open-source components.

So, if you are in Toronto next Wednesday and you can't wait to see me screw up in front of an audience, or if you're just interested in the cheap beer, make sure your at the Resistor Gallery at Collage and Spadina. It's a little hard to find from the street, but if I recall correctly it's right next to a paint store.

I'll be speaking at Flash in the Can 2007

Flash in the can It's confirmed! I get to speak at flash in the can 2007. This is great news for me, as I wanted to speak at tech conferences for a while now.. but finally I got in.

Flash in the can is a flash conference held in toronto for a few years now and it is one of the most important conferences in North America. It is actually the first tech conference I attended.

Irony is that I'm not that much into flash.. Much of my work is related to opensource and standards-based development, but in this area you can have a religion about technology, but in practice you have to set that aside for realism and pick the right tool for the job.

Currently flash is simply the number one way to bring video content to the browser in both user adoption and usability. I kind of rolled into the video thing by accident, because one of my earlier clients requested a user generated video application.. That ball kind of kept on rolling and developing video-enabled web applications has been my main role ever since.

The title of my presentation is Flash Video Lifecycle: From User To Delivery. I will be covering uploading using flash, handling uploads using php, converting with FFMpeg and delivering video using Flash.

I'm very excited, and hopefully I will be able to jumpstart and inspire the people who are into this sort of thing, but don't know where to start. If your there, be sure to say hi!

FFMpeg supports FLV 1.1

I still need to confirm this out myself if its true, but looking at the updates in the source it seems as if FFMpeg is now injecting FLV metadata in the latest svn sources.. This means we don't have to use a tool like FLVTool2 anymore after transcoding videos.

Also, they decided a while ago to switch from CVS to subversion. Which is nice, because I use SubVersion for all my projects and now I can use ffmpeg as an external definiation.

The best news is yet to come, FFMpeg has 5 projects in Google's Summer of Code. In this program google funds people who are willing to do open source programming for a project of choice. Among those projects is a VC-1 decoder, which allows transcoding WMV3/WMV9, an AAC decoder (AAC is heavily used in MOV/MP4 videos) and an AMR encoder/decoder (AMR is used in 3GP, 3G2).

Good stuff, I've been following the project for a while now and I'm happy to see its still this active.

 1

About

My name is Evert, and I've been writing semi-regularly on this blog since 2006.

I'm currently available for contract work.

more info.

Subscribe

Dropbox

Dropbox is a simple cross-platform online backup and sync application. The first 2GB of space is free, and both you and me get an extra 250MB extra space if you sign up through this link.