Good Introduction for Flash Video
Original:?http://osflash.org/flv Flash?Video?(FLV)Flash?Video?is the name of a?file?format used to deliver?video?over the Internet using Adobe Flash Player version 6 or newer. Flash?Video?content may also be embedded within SWF files. Until version 9 update 3 of the Flash Player,Flash?Video?referred to a proprietary?file?format,having the extension .FLV?but Adobe introduced?new?file?extensions and MIME types?and suggests to use those instead of the old?FLV:
It is possible to place H.264 and AAC streams into the traditional?FLV?file,but Adobe strongly encourages everyone to embrace the new standard?file?format. There are functional limits with the?FLV?structure when streaming H.264 which couldn't be overcome without a redesign of the?file?format. This is one of the reasons Adobe is moving away from the traditionalfile?structure. Specifically dealing with sequence headers and enders is tricky with?FLV?streams. Adobe is still working out if it's possible to place On2 VP6 streams into the new?fileformat. Overview
IssuesTools to solve?FLV-related issues:
FLV?Metadata Injector?- free closed-source tool which can inject metadata information into a?
FLV?
file
VideoOverviewYou load and play .mp4,.m4v,.m4a,.mov and .3gp files using the same NetStream?API?you use to load?FLV?files. There are a few things to be aware of:
the Flash Player is close to 100% compliant to the H.264 standard,all Base,Main,High and High 10 bit streams should play.
Extended,High 4:2:2 and High 4:4:4 profiles are not officially supported at this time. They might or might not work depending on what features are used. There are no artificial lower limit on B-frames or any problems with B-pyramids like other players do.
Since these files contain an index unlike old?
FLV?files,the Flash Player provides a list of save seek points,e.g. times you can seek to without having the play head jump around. You'll get this information through the onMetaData callback in an array with the name 'seekpoints'. On the downside,some files are missing this information which also means that these files are not seekable at all! This is very different from the traditional?
file?format which is rather based on the notion of key frames to determine the seek points.
Codecs
Adobe Tech Note Audio Overview
Audio can be either?
AAC?Main,AAC LC or SBR,corresponding to audio object types 0,1 and 2.
The '.mp3'?
sample?type for tracks with mp3 audio is also supported.
MP3inMP4 which intends to do multi-channel mp3 playback within mp4 files is not supported.
The old QuickTime specific style of embedding AAC and?
MP3?data is not supported. It is unlikely though that you will run into these kind of files.
Unencrypted audio book files contain chapter information. This information is exposed in the onMetaData callback as an array of objects with name 'chapters'.
The Flash Player can play back multi-channel AAC files,though the sound is mixed down to two channels and resampled to 44.1Khz. Multi channel playback is targeted for one of the next major revisions of the Flash Player. This requires complete redesign of the sound engine in the Flash Player which dates from circa 1996 and has not been improved since.
All sampling rates from 8Khz to 96Khz are supported. A 32 tap?
Kaiser Bessel?based FIR filter which resamples the sound to 44.1Khz,retaining high quality. The most common?
sample?rate combinations have a hard coded number of phases. In case of a 48000 to 44100 Hz conversion the filter has 147 phases f.ex.
Flash Player Update 3 Beta 2 now can play back any?
MP3?sampling rate leveraging the same AAC implementation. No more chipmunks. Ever.
Codecs
Image
Image tracks encoded in?
JPEG,?
GIF?and?
PNG?are accessible in AS3 as a byte array through the callback 'onImageData'. You can simply take that byte array and use the Loader class to display the images. Most often these images represent cover artwork for audio files.
TIFF?image tracks are not supported,you might come across files using this.
Support for the 'covr' meta data stored in iTunes files,accessible as byte arrays.
Metadata
FLV?FormatA Flash?Video?file?(.file?extension) consists of a short header,and then interleaved audio,?video,and metadata packets. The audio and?video?packets are stored very similarly to those in?SWF,and the metadata packets consist of?AMF?data. FLV?Header
FLV?Stream
Then a sequence of tags?followed?by their size until?EOF. FLV?Tag
Previous tag size
FLV?Tag Types
FLV?Tag 0x08: AUDIOThe first byte of an audio packet contains bitflags that describe the codec used,with the following layout:
The rest of the audio packet is simply the relevant data for that format,as per a?SWF?SoundStreamBlock. FLV?Tag 0x09:?VIDEOThe first byte of a?video?packet describes contains bitflags that describe the codec used,and the type of frame
In some cases it is also useful to decode some of the body of the?video?packet,such as to acquire its resolution (if the initial onMetaData META tag is missing,for example). TODO: Describe the techniques for acquiring this information. Until then,you can consult the?flashticle?sources. FLV?Tag 0x12: METAThe contents of a meta packet are two?AMF?packets. The first is almost always a short uint16_be length-prefixed UTF-8 string (AMF?type 0x02),and the second is typically a mixed array (AMF?type 0x08). However,the second chunk typically contains a variety of types,so a full?AMF?parser should be used. HTTP StreamingIt is possible to semi-stream?flv?over http using a trick which sends the normal headers then skips forward to a desired point in the?file?and moves the timestamps forward accordingly. A?sample?php script and fla is available at FlashComGuru Another tool that you can use to stream?flv?files using http is using?Flv4PHP?this tool is both a?FLV?Metadata injector and a stream tool,using php 4.x. this Project is?GPL.
1)?The support of AAC allows you to encode audio to 64Kbit/s with the same quality of a 128Kbit/s encoded?
MP3. Further more,for other use more susceptible to bandwidth usage,like Internet Radio,HE-AAC v2 gives the possibility to encode audio to 32Kbit/s or lower with a surprisingly good final result. In low bitrate streaming scenarios this can make the difference.
2)?Flash documentation does not state a number for “their” version of Sorenson but describes the codec as a variant of?
ITU-T?(International Telecommunications Union-Telecommunication Standardization Sector) recommendation?
H.263?(
MPEG-4_V). In early 2006,one of Sorenson's compression applications to produce content for Flash offered the?
Sorenson_3?codec,described by experts as a variant of ITU-T H.264 (
MPEG-4_AVC). By late 2006,Sorenson offered new compression applications with other outputs.
3)?This codec divides the screen in wide macroblocks (es: 64×64 pixels),reduces the number of colors,and transmits the changed blocks after compressing them in?
zlib. This is very similar to what VNC does.formats are bitmap tile based,can be lossy by reducing color depths and are compressed
4)?This codec can use two different types of macroblock: Iblock and Kblock. The Kblock works like a keyframe and is archived for future references. The Iblock is encoded as differences from a previous block. This new approach,similar to the usual compression of generic?
video?content,guarantees a much better compression ratio,especially in a standard “moving windows” scenario.
|
Discussion