Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:FLV

From ReverseEngineering.wiki
Format
On this wiki Facts · Code · Notes · Topics

Adobe Flash Video (.flv): a 9-byte header 'FLV' + version + flags (bit 0 video, bit 2 audio) + data offset, then a repeating sequence of PreviousTagSize (u32, first one 0) and tags with an 11-byte header; tag types 8 audio, 9 video, 18 script data (AMF metadata with onMetaData).

Overview

All multi-byte fields are big-endian. Header: bytes 'F' 'L' 'V', version byte (FFmpeg's probe requires it below 5), flags byte (FLV_HEADER_FLAG_HASVIDEO = 1, FLV_HEADER_FLAG_HASAUDIO = 4), u32 DataOffset (header size, normally 9; FFmpeg requires it above 8). FFmpeg's probe also requires the byte at offset 5 (high byte of DataOffset) to be 0.

Body

At DataOffset comes PreviousTagSize0 (u32, always 0), then repeated tags: u8 TagType (low 5 bits, & 0x1F), u24 DataSize, u24 Timestamp plus u8 TimestampExtended (the high byte, bits 24-31), u24 StreamID (always 0), the data, then u32 PreviousTagSize = DataSize + 11.

Tag types

8 audio, 9 video, 0x12 (18) script data. Audio tag first byte: codec id in the high nibble (mask 0xF0), sample rate bits 0x0C, sample size bit 0x02, channel bit 0x01. Video tag first byte: frame type in bits 0x70 (shifted by 4), codec id in the low nibble (mask 0x0F); the flag 0x80 marks the Enhanced RTMP extended video header. Composition time for AVC/HEVC packets is a signed 24-bit value.

Metadata

The first script tag holds an AMF0 'onMetaData' ECMA array; FFmpeg uses the keys 'keyframes' with 'times' and 'filepositions' as a seek index. Unverified: AMF0 value type numbers (0 number, 2 string, 3 object, 8 ECMA array, 9 object end) are from the Adobe spec, not read in the checked lines (only AMF_END_OF_OBJECT 0x09 was).

Code & repositories

  • https://github.com/FFmpeg/FFmpeg @ c2bbf2b83d064313ca3739f81c651553cfbb26fb · license: LGPL-2.1-or-later (declared by the contributor; GitHub's detector did not recognize COPYING.GPLv2)
    FFmpeg libavformat demuxers smacker.c, idroqdec.c, flvdec.c, mpegts.c
    Tested on: source read, not run: source reading only · checked 2026-10-18; last activity 2026-10-18

Evidence & references

  • FFmpeg libavformat/flv.h and flvdec.c (LGPL-2.1+).