Skip to content

Instantly share code, notes, and snippets.

@kmod-midori
Created September 6, 2024 09:20
Show Gist options
  • Save kmod-midori/160349e9462c106f45bc72a2cb3cabcf to your computer and use it in GitHub Desktop.
Save kmod-midori/160349e9462c106f45bc72a2cb3cabcf to your computer and use it in GitHub Desktop.
ImHex pattern for FLV files
#pragma endian big
struct Header {
char signature[3];
u8 version;
u8 flags;
u32 data_offset;
};
struct ScriptDataString {
u16 len;
char data[len];
};
struct ScriptDataObject {
ScriptDataString name;
};
struct ScriptData {
ScriptDataObject objects[1];
};
bitfield AudioHeader {
format: 4;
rate: 2;
size: 1;
type: 1;
};
struct AudioData {
AudioHeader header;
if (header.format == 10) {
u8 aac_packet_type;
}
};
bitfield VideoHeader {
frame_type: 4;
codec_id: 4;
};
struct VideoData {
VideoHeader header;
};
struct UnknownData {};
struct Tag {
u32 prev_tag_size;
u8 type;
u24 data_size;
u24 timestamp;
u8 timestamp_ext;
u24 stream_id;
if (type == 8) {
AudioData data;
} else if (type == 9) {
VideoData data;
} else if (type == 18) {
ScriptData data;
} else {
UnknownData data;
}
padding[data_size - sizeof(data)];
};
Header header @ 0x00;
Tag tag[10] @ 0x09;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment