Every bitmap or sound imported into the library is kept in a
Media stream of its
own, named Media n, or in Flash CS4 M n
stamp. Unlike the other streams, a Media stream is not an archive of
objects: it is the data itself. What the item is called, and the file it came from, are
in its media record in
Contents. No thumbnail or preview image was found in any binary FLA.
JPEG
When the bitmap’s media record gives a JPEG length, the stream is that many bytes of a JPEG file, kept whole as it was imported, then four s32: the bounds, left, right, top and bottom in twips. Reading the JPEG part gives a file that any image program opens. The explorer shows it, however the stream’s sectors lie.
Lossless bitmaps
Bitmaps that are not JPEGs are kept in Flash’s own lossless form, the raster: a short header, an optional palette, then the pixels, usually as a zlib stream split into chunks. Little-endian throughout.
| Field | Present | Meaning |
|---|---|---|
| u8 | always | The raster’s revision: 3 in every file of this format seen. |
| u8 | always | The pixel format, below. |
| u16 | always | Row size: bytes a row, with any padding. |
| u16, u16 | always | Width and height in pixels. |
| 4 × s32 | always | The bounds in twips (1/20 pixel): left, right, top, bottom; normally 0, width × 20, 0, height × 20. |
| u8 | revision 3 | Bit 0: the bitmap has transparency. |
| u16 + colours | format below 4 | The palette: a count (up to 256), then the colours, four bytes each from revision 3 (alpha, red, green, blue), earlier three u16 each. |
| u8 | revision 2 or more | 1: the pixels are zlib data in chunks; 0: raw. Revision 1 is always compressed, revision 0 never. |
| chunks | compressed | Each a u16 length and that many bytes, until a length of 0. |
| row size × height bytes | raw | The pixels. |
| Format | Pixels |
|---|---|
| 5 | Four bytes a pixel: alpha, red, green, blue, the colours premultiplied by alpha (colour × alpha ÷ 256). |
| 3 | One byte a pixel, an index into the palette. Common in Flash 8 files, absent from the CS3 and CS4 files examined. |
| 4 | No palette; two bytes a pixel, read as a big-endian 16-bit word: bit 15 is unused, then 5 bits each of red, green and blue (bits 14 to 10, 9 to 5 and 4 to 0). JPEXS widens each 5-bit value to 8 bits with a 32-entry table, 0, 15, 23, 31, 39, 47, 55, 63, 71, 79, 87, 95, 95, 111, 119, 127, 135, 143, 151, 159, 167, 175, 183, 191, 199, 207, 215, 223, 223, 239, 247, 255. No file examined here holds this format. |
| 0 to 2 | These also have a palette, and each pixel is an index of 1 << format bits: 1 bit (format 0), 2 bits (1) or 4 bits (2), the first pixel of a byte in its high bits, rows padded to the row size. None was seen in this format. |
The pixel formats 0 to 4 are as the JPEXS FLA converter reads them
(jpexs-fla-convert,
exporter/XflBitmapWriter.java, read 2026-11-13): the bits a pixel are 1
<< format below format 4, 16 in format 4 and 32 in format 5; the row size must be
at least that many bits a row; the colours are premultiplied by alpha; and when the
header’s transparency flag is 0 the bitmap is read as opaque whatever its alpha bytes
hold. The same converter’s BitmapRecordDecoder.java reads the header,
palette (formats below 4 only), compressed flag and chunks exactly as the table above
lays them out.
To decode a compressed raster:
- Join the chunks in order. The result is one zlib stream; it starts with the zlib
header, often
78 01. - Inflate it to row size × height bytes.
- Read the rows: four bytes a pixel in format 5, two in format 4, a palette index of 1 << format bits in formats 0 to 3.
03 05 A4 00 29 00 A0 01 00 00 00 00 34 03 00 00 00 00 00 00 80 20 00 00 00 01 02 00 78 01 …
78 01, the zlib headerEarlier pages here read the first two bytes, 03 05, as a signature; they
are the revision and the format. The same raster is used for the .dat
bitmaps of the later XFL documents. There,
decoding a bitmap beside the PNG it was imported from confirmed the order alpha, red,
green, blue and the premultiplying; the JPEXS converter writes Media streams in the
same order. (Kreijstal’s notes give alpha, blue, green, red.)
Sounds
An imported sound’s stream has no header of its own: its format, rate and length are
in the sound’s media
record in Contents, whose format flags give the codec, rate, sample
size and channels.
- PCM (codec 0 or 3): the samples, sample count × bytes a sample × channels bytes. 16-bit samples are signed little-endian; 8-bit samples are read as unsigned, as in WAV. JPEXS’s converter wraps these bytes unchanged in a WAV header (8-bit WAV data is unsigned), which is the only public support for that reading.
- A compressed codec (MP3 and the others): the encoded data, of the length the record gives; then a u8, and an uncompressed PCM copy of the sound in the record’s second format and sample count.
Every sound in the files examined is PCM or MP3. The explorer plays them all, decoding MP3 itself. For ADPCM, GSM and Nellymoser, which Flash names among its codecs, it plays the uncompressed copy when there is one. When there is not, it shows the stored bytes as a labelled section: the codec number and name, the format, the sample count, the length of the compressed data, its first 32 bytes, and the marker byte and second format that follow.
What a public source settles, from the JPEXS FLA converter
(jpexs-fla-convert,
reader/MediaPayloadRecordDecoder.java, reader/FlaSoundFormat.java
and exporter/XflMediaWriter.java, read 2026-11-13): the stream is the
primary audio, then, for any codec other than 0, a marker byte and the second audio. The
primary audio is as long as the record’s encoded byte count when the codec is not 0 and
that count is above 0, otherwise sample count × bytes a sample × channels. The second
audio is the PCM size of the record’s second format and second sample count. A stream
that ends before the audio has run out is accepted as it is (the converter calls this
a short read). The codec number is bits 4 to 7 of the format word: 0 PCM, 1 ADPCM, 2
MP3, 3 PCM, 4 GSM, 5 Nellymoser 8 kHz mono, 6 Nellymoser, anything else unknown (the
converter says only the codec numbers named by Flash’s own sound-cache diagnostics are
named). The format word is stored 4 lower than it is read when the record’s revision is
below 5 (the converter adds 4), which the explorer does too. For codec 1, 4, 5 and 6
the converter keeps the encoded bytes untouched and has no decoder: its own warning is
“no standalone source decoder for codec”. So the framing is public, and the bit layout
of the ADPCM, GSM and Nellymoser data inside is not: it is Unknown in the Not described
section of the family page.
Video
A CMediaVideoStream’s stream (embedded video) holds:
| Field | Meaning |
|---|---|
| u8 | Revision: 2 in Flash MX 2004, 3 in Flash 8. |
| u32 | The video type, the codec: 0 no media, 1 jpeg media, 2 h263 media, 3 screen share media, 4 vp6 media, 5 vp6 alpha media, 6 screen v2 video packet, 7 avc video packet, 8 count media type, any other number unknown. These are the names the JPEXS FLA converter writes into the XFL videoType attribute for each number (exporter/XflMediaWriter.java, method video, read 2026-11-13); they are the schema’s enumeration in the same order. |
| f64, f64 | Frame rate; audio sample rate. |
| s32, s32 | Audio bits a sample, audio channels. |
| s32, s32 | Width and height in pixels. |
| f64 | Length in seconds. |
| u32, u8, u8 | The isSpecial flag (the converter’s name for it; what it means is not established); import the audio; synchronise the video to the document’s frame rate. |
| u32, s32, f64, u32 | The import settings: frame drop ratio (an index), quality, scale and keyframe interval. |
| 2 tracks | Each a u32 kind, index entries (a non-zero u8, then s32 offset, byte count, frame count and flags) ended by a zero byte, then a u32 byte count and the data. |
| u32, CString, u32 + bytes | From revision 3: whether a device video is bundled, its source path, and its bytes. |
The same layout is an XFL document’s video .dat file. The explorer shows
these fields and every index entry of each track (offset, byte count, frame count,
flags). The tracks hold the video and sound as Flash compressed them on import. The
explorer reads each entry’s bytes with the decoder of the codec the video type names,
using the decoders it has for SWF and FLV and changing none of them: Sorenson H.263
(type 2, described in the SWF specification), Screen Video and Screen Video 2 (types 3
and 6), On2 VP6 and VP6 with alpha (types 4 and 5), and JPEG (type 1). When the entry
reads as that codec’s picture, the picture type, size and quantiser (or the codec’s own
header) are shown and the first and last picture of the track are decoded as images; an
entry that does not read as the named codec is tried as Sorenson H.263, then listed
with the reason and its first bytes. Type 7 (AVC) is split into NAL units and its parameter
sets, SEI messages and slice headers are read and the first and the last picture are drawn
with the explorer's H.264 decoder (progressive streams); the framing is told from the bytes, and the joined Annex B stream
opens as an .h264 entry. Types 0, 8 and unknown are listed, not decoded.
Established from 5 real files: the
0015_videos.fla files for CS4, CS3, Flash 8, Flash MX 2004 and Flash MX
(the last in the single-byte form), each holding the clips
h263_nosound.flv, vp6_sound.flv and
vp6_sound_mono_rain.flv, from the test data of
jindrapetrik/flacomdoc
(testdata/fla/, an LGPL-2.1 repository by the author of the converter,
read 2026-11-13). The Media streams carry the same names and times in all five, so
they may have been saved down from one document rather than authored in each release;
the bytes read are the same either way:
- Offsets count from the start of the track’s data, and the entries follow one
another without gaps: in
vp6_sound.flvthe three entries are 0 + 827, 827 + 100 and 927 + 129 bytes, which fill the track’s 1,056 bytes exactly. The first index entry of a video track has a flags value of 5 and the others 4 in the two short clips (bit 0 is set on the key frame; the meaning of the other bits is not known). - Each entry is one frame (frame count 1) in all three clips; the Sorenson H.263 entries (types 2) start at the picture start code and need no prefix.
- A VP6 entry (types 4 and 5) is an FLV video tag body without its codec byte: it
opens with the one-byte horizontal and vertical adjustment (0 in every entry read),
then the VP6 frame. The first entry of
vp6_sound.flvreads00 5e 46 04 02 04 02: adjustment 0, a key frame of quantiser 47, version 8, 4 × 2 macroblocks of the display. The VP6 alpha form (type 5) is the same byte followed by the 3-byte alpha offset, as in FLV; no real file holds one. - The second track (kind 1) is the audio, as raw little-endian PCM at the payload’s
rate, bits and channels, in one entry with flags 0 (the 23,040 bytes of
vp6_sound.flvare 5,760 stereo frames of 16 bits at 44,100 Hz; the 444,672 bytes ofvp6_sound_mono_rain.flvare 222,336 mono samples of smooth waveform, 5.04 seconds although the video is 6.25 seconds). The track of a video without sound has no entry. A video’s audio is therefore stored as PCM, not in the codec of the source file. isSpecialis 0 in every video read (three clips, five files); its meaning is still not known.- Revision 2 (Flash MX 2004 and the MX files) lacks the device-video tail of revision 3 and is otherwise the same.
The explorer shows the audio track as a playable sound and decodes the H.263 and VP6 pictures of these files (32 × 64 and 256 × 144). Not read from a real file: Screen Video, JPEG and VP6 alpha entries, an entry of more than one frame, and AVC. The decoding of those is tested on pictures and headers built by hand.