Flash opens up

Pretty big news coming from Adobe today, as they opened up the specification for the SWF and the FLV / F4V formats.

This basically opens the door to play banner ads and intro's properly in alternative players, such as Gnash and it should also help development of flash video streaming projects such as red5.

Gnash actually has a fair support for the SWF format, but because of the legal restrictions around the spec they were never allowed to read the spec. Now they should be able to implement the full SWF format easily.

I've been following a lot of adobe/macromedia blogs over the years through MXNA (currently down) and attended some flash conferences, and about half of the flash developers always seem to use the argument 'if there's other flash players out there, incompatibilities will arise', basically favouring a closed spec. I always had a feeling this was strongly influenced by Adobe/MM propaganda, so it will be interesting to see if the majority of the community changes their opinion after this news.

As for my opinion, I'm biased. The news is great for end-users, for sure. Currently the flash player is said to be installed on 98% of all computers hooked up to the net, which is higher than the market share of IE, or Windows. This makes it the best possible platform to target for security holes. It also removes the vendor-lock in and it can improve competition and therefore innovation. I don't like it, because SWF is a messy binary format and I rather see a prettier text-based formats such as HTML 5, SVG and Javascript 2 finished and gain adoption.

Mime types.. when will people learn?

HTTP has an incredible useful feature to supply the Content-Type HTTP header for any url. This allows HTTP clients to easily figure out what type of data they're getting.

Over and over again I see clients, not doing this and making assumptions based on the url. The extension of all things! This is some artifact inherited from ms-dos, and passed on to different operation systems when GUI's became popular.

Two clear examples I have today (and I'm sure many people will have examples like this)

  • Flash's VideoPlayer component. If there's no extension in the url, it will assume its some kind of xml file.
  • iTunes podcasts.. Files have to end with a known extension for iTunes to pick it up as a video or audio file. Even though the Mime type has to be specified in both the RSS feed and the HTTP Header!

WTF?

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.

FLVTool2 broken

To make FLV's coming from flash streaming servers (FCS/FMS/Red5) properly work as a progressive download, it's often required to use a tool to inject 'missing' meta-data.

Up until now I used FLVTool2 for this, but it seems to load the entire FLV into memory (badd!), and now I'm getting nasty errors as well..

  1. ERROR: EOFError
  2. ERROR: /usr/local/lib/site_ruby/1.8/flv/amf_string_buffer.rb:37:in `read'
  3. ERROR: /usr/local/lib/site_ruby/1.8/flv/amf_string_buffer.rb:243:in `read__STRING'
  4. ERROR: /usr/local/lib/site_ruby/1.8/flv/audio_tag.rb:56:in `read_header'
  5. ERROR: /usr/local/lib/site_ruby/1.8/flv/audio_tag.rb:47:in `after_initialize'
  6. ERROR: /usr/local/lib/site_ruby/1.8/flv/tag.rb:56:in `initialize'
  7. ERROR: /usr/local/lib/site_ruby/1.8/flv/stream.rb:447:in `new'
  8. ERROR: /usr/local/lib/site_ruby/1.8/flv/stream.rb:447:in `read_tags'
  9. ERROR: /usr/local/lib/site_ruby/1.8/flv/stream.rb:58:in `initialize'
  10. ERROR: /usr/local/lib/site_ruby/1.8/flvtool2/base.rb:272:in `new'
  11. ERROR: /usr/local/lib/site_ruby/1.8/flvtool2/base.rb:272:in `open_stream'
  12. ERROR: /usr/local/lib/site_ruby/1.8/flvtool2/base.rb:238:in `process_files'
  13. ERROR: /usr/local/lib/site_ruby/1.8/flvtool2/base.rb:225:in `each'
  14. ERROR: /usr/local/lib/site_ruby/1.8/flvtool2/base.rb:225:in `process_files'
  15. ERROR: /usr/local/lib/site_ruby/1.8/flvtool2/base.rb:44:in `execute!'
  16. ERROR: /usr/local/lib/site_ruby/1.8/flvtool2.rb:168:in `execute!'
  17. ERROR: /usr/local/lib/site_ruby/1.8/flvtool2.rb:228
  18. ERROR: /usr/bin/flvtool2:2:in `require'
  19. ERROR: /usr/bin/flvtool2:2

I wanted to try out FLVTool++ anyway, as it seems like a much more scalable solution.. This is how its installed on debian:

Grab the source:

  1. wget "http://rcdn.org:8080/images/4/44/Flvtool%2B%2B.tar.bz2"

Unpack

  1. tar xfvj Flvtool++.tar.bz2

Make sure you have a compiler installed (as root).

  1. apt-get install build-essential

Compiling

  1. make

AArrghh! It doesn't compile :(. This is the error it gave me:

  1. g++ -O2 -c -Wall -D_FILE_OFFSET_BITS=64 flvtool.cpp -o flvtool.o
  2. AMF.h:35: error: invalid pure specifier (only `= 0' is allowed) before ';' token
  3. flvtool.cpp: In function 'int main(int, char**)':
  4. flvtool.cpp:192: warning: too many arguments for format
  5. make: *** [flvtool.o] Error 1

Ok, lets dig into this code a bit.. the errors seems to give a few useful hints..

First thing I did was go to line 35 in AMF.h and change:

  1. virtual std::ostream& operator << (std::ostream& os) const = NULL;

into:

  1. virtual std::ostream& operator << (std::ostream& os) const = 0;

Next, open flvtool.cpp (line 192) and change:

  1. fprintf(stderr, "usage:\n", argv[0]);

Into:

  1. fprintf(stderr, "usage:\n");

Now, for some reason you also need to manually create the bin/ directory in your source directory, after that you can start compiling again.

  1. mkdir bin
  2. make

Success! Your bin/ directory will now contain the flvtool++ binary

  1. ./bin/flvtool++
  2. #outputs:
  3.  
  4. flvtool++ version 1640 2007/05/24 14:39:18
  5. usage:
  6. flvtool++ <input file> <output file> (<start time> <end time>)
  7. flvtool++ -i <input file>

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. ?>

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.