Choosing a Flash video format for pseudostreaming

Introduction

StarburstWe’ve been spending a lot of time recently examining the different video codecs available for Flash and conducting various tests. Our objective has been to choose the best quality video format which also enables pseudostreaming – without using custom servers such as Lighttpd.

Pseudostreaming means imitating the behaviour of a RTMP streaming server such as Red5 or Flash Media Server by simply using a PHP script such as xmoov.php. Using such a solution does not enable collaborative behaviour such as the broadcasting of live webcam streams, but it does allow jumping ahead to parts of a video which have not yet downloaded. This is probably the benefit most people seek from a streaming server solution and it is much easier to set up than a streaming server. It is the choice of YouTube and Google Video.

What’s required for pseudostreaming?

Pseudostreaming requires a video format which supports it and a video player which supports it too. Two leading open source video players, JW Player and Flowplayer both support it, because they send a request indicating how much of the video file should be sent back.

Flowplayer requires a plugin SWF. This player is configured using JSON. JSON is not especially complicated but we found this config method fairly verbose. It also uses its own flash embed routine. You have to get the config exactly right for pseudostreaming via xmoov to work with Flowplayer. There are scarce resources on the web. The main one points to this page, which is now outdated, but it can be done, and if you need to know how, ask us.

We find JW Player easier to configure for pseudostreaming with xmoov. The info page is here and after we pointed out a fault with the player, here, the latest release works properly with pseudostreaming.

Comparing video formats

Perhaps we will use JW Player as our player, then, but we’re still no closer to deciding which video format to use.

H.264 & F4V

It seems safe to say that the best quality format for the web at the moment is the H.264 standard. We are seeking to encode video using Adobe Media Encoder, which is included with Creative Suite 4. This program uses the MainConcept H.264 Video codec and using this codec it can encode into either MP4 format or F4V format. At least Flash Player 9.0.115.0 is required to play back this standard.

F4V was created by Adobe in order to address shortcomings in the FLV format. It determines additional file meta data and enables the embedding of H.264 video in this custom format.

At the time of writing, according to our research, you can forget about using H.264 for pseudostreaming unless you have shell access to your Linux server and wish to try compiling a PHP module like this or you are using lighttpd as your web server.

Neither Flowplayer nor JW Player support pseudostreaming of either F4V or MP4 videos using the H.264 standard along with xmoov.php.

Eric Lorenzo Benjamin Jr of xMoovStream also offers his own video player, which looks good, and a separate streaming server solution. This can stream MP4 (H.264) files to Apple’s iPhone and Quicktime, but not to Flash Player. We’re still limited to FLVs with this player.

F4V problems

A little more about F4Vs while we are on the topic: the format currently appears to be faulty – at least when encoded by Adobe Media Encoder CS4:

  • It does not add keyframes at navigation cue point times
  • It does not trigger cue point event listeners in the expected manner
  • It does not respect custom keyframe intervals

Some more reasons not to use this format yet, perhaps, despite Adobe having urged everybody to switch to it. If you wish to have high quality video without xmoov pseudostreaming, use MP4 instead for now. (Under our tests, MP4s embed seekpoints correctly whereas F4Vs do not.)

We’re left only with trusty old FLV as the format we can pseudostream.

Setting up FLVs for pseudostreaming

Choosing a codec

You have a choice of two different codecs when exporting FLVs using Adobe Media Encoder: Sorenson Spark or On2 VP6. The latter is the later, recommended, codec.

Choosing a keyframe interval

Notice the option to “Set Keyframe Distance” in the Export Settings under Video → Advanced Settings. When using pseudostreaming the player can only jump to the closest keyframe. The more keyframes, the more precise your pseudostreaming will be, but the larger your file will be.

The default is a keyframe interval of 30. If you take this down to 10 you will see a lot more precision and about a 17% rise in file size. If you take it down to 1, though, you will see a 1000% rise in file size along with your optimal precision. You will also find that the video player takes a long time reading the meta data of the FLV before it plays it. We are happy with the compromise of a keyframe interval of 10.

So you export the video using whatever quality you like, and this keyframe interval. You stream it into your player using referring to the config links above. You try seeking to a part of the video which has not yet downloaded. The playhead simply jumps back to the beginning of the video. What’s going on?

Inserting meta data

Well, it’s not enough to have the keyframes in the video. What Adobe Media Encoder unfortunately does not do is insert meta data in the FLV indicating where those frames are. This is vital for php pseudostreaming to work. (Adobe: please provide the option for this in the next release of AME.)

Luckily, there is quite a dated freeware tool from Buraks, of the ActionScript Viewer, which still does the job well: FLVMDI. There is even a GUI available so you don’t need to start working on the command line, and another tool enabling you to view the meta data without tracing it out using Flash.

Once you have exported your FLV file with the ideal keyframe interval, you’ll need to run it through FLVMDI to insert the meta data. Be sure to tick the “Include ‘keyframes’ object” option. It performs this task quickly, then, when you use the file with JWPlayer and xmoov, you should find you can move the playhead to any location and the file will “stream” from there.

Conclusion

The conclusions to be drawn at this point, we believe, are as follows:

  • F4V is a no-go area as there are problems with the format.
  • MP4 (H.264) is the optimal format if you do not require pseudostreaming via xmoov.
  • FLV remains the best format to use if you do wish to pseudostream using these players.

Since pseudostreaming is highly desirable, then, and xmoov is a quick and easy solution, we find FLV to be still the best format.

We hope this article helps get you up and running with Flash video including pseudostreaming. If you spot any problems with it do let us know, and if the article proves popular we may expand on it and insert relevant images.

Cheap web hosting

Comments on this post

  1. myq says:

    top notch work! very useful and clear. i really appreciate it.
    any tips on using the VP6 codec? I can’t figure out how to specify it when encoding. Most programs seem to default to Sorenson.
    cheers!

    • Orland Media says:

      Thanks. You might not be using a late enough version of Media Encoder? In CS4 you can select VP6 or Sorenson using a radio button under the “Video” tab.

  2. jaster says:

    I happy to read your post.
    but , I’ve some opinion this text. FV4 and mp4 is same format. If you wanna adding seek points or etc data to F4v , you can use the idom atom accrodding to atom of Standard mp4 spack. then decoe with flash actionscript. Isn’t it?

  3. Great post! Very informative and well rounded. I just wanted to note, xmoovStream does stream F4V files.

    Keep up the good work!

  4. Valeriu Palos says:

    Tere’s also Loomiere/Stream for a dedicated streaming solution. It features good performance, and soon version 2.0 will be available, which will be even stronger.

  5. Justin says:

    Great post.  I only wish I had have read this about 3 hours ago before researching and deciding that h.264 in the f4v container would be best for my purposes.  I pseudo stream with xmoov so it’s disappointing to hear that h.264 is a no-go and i’m stuck with flv.  Hopefully updates come soon which make it possible.

    Thanks again for the informative article.
    Cheers,
    Justin

  6. Supriya Tenany says:

    I have used the following properties in the meta data handler for finding the keyframes, but returned nothing:

    var kfPoints:Object;
    for (var propName:String in metaInfoObj) 
    {
    if (propName == "keyframes")
    {
    trace ("Keyframes received");
    var kfObject:Object = metaInfoObj[propName];
    kfPoints = kfObject["times"];
    }
    }
    

    How can I find keyframes in an mp4 file transcoded with an H264 codec?

  7. dmitry says:

    Great post!

    I would like to note that I’ve successfully used H.264 encoded video with JW Player and xmoov.php.
    How?
    I just encoded the source files into .264 and .aac files and muxed them into FLV container.
    I’ve used the following software – mencoder, faac, ffmpeg and yamdi.
    It really works.

Add a comment:

*