2021-09-19 11:27:56 +03:00
|
|
|
## Supported formats
|
|
|
|
|
2022-02-05 20:15:18 +03:00
|
|
|
[./formats_table.sh]: sh-start
|
|
|
|
|
2022-01-13 20:34:59 +03:00
|
|
|
|Name |Description |Dependencies|
|
|
|
|
|- |- |-|
|
|
|
|
|`aac_frame` |Advanced Audio Coding frame |<sub></sub>|
|
|
|
|
|`adts` |Audio Data Transport Stream |<sub>`adts_frame`</sub>|
|
|
|
|
|`adts_frame` |Audio Data Transport Stream frame |<sub>`aac_frame`</sub>|
|
|
|
|
|`apev2` |APEv2 metadata tag |<sub>`image`</sub>|
|
|
|
|
|`ar` |Unix archive |<sub>`probe`</sub>|
|
|
|
|
|[`asn1_ber`](#asn1_ber) |ASN1 Basic Encoding Rules (also CER and DER) |<sub></sub>|
|
|
|
|
|`av1_ccr` |AV1 Codec Configuration Record |<sub></sub>|
|
|
|
|
|`av1_frame` |AV1 frame |<sub>`av1_obu`</sub>|
|
|
|
|
|`av1_obu` |AV1 Open Bitstream Unit |<sub></sub>|
|
|
|
|
|`avc_annexb` |H.264/AVC Annex B |<sub>`avc_nalu`</sub>|
|
|
|
|
|`avc_au` |H.264/AVC Access Unit |<sub>`avc_nalu`</sub>|
|
|
|
|
|`avc_dcr` |H.264/AVC Decoder Configuration Record |<sub>`avc_nalu`</sub>|
|
|
|
|
|`avc_nalu` |H.264/AVC Network Access Layer Unit |<sub>`avc_sps` `avc_pps` `avc_sei`</sub>|
|
|
|
|
|`avc_pps` |H.264/AVC Picture Parameter Set |<sub></sub>|
|
|
|
|
|`avc_sei` |H.264/AVC Supplemental Enhancement Information |<sub></sub>|
|
|
|
|
|`avc_sps` |H.264/AVC Sequence Parameter Set |<sub></sub>|
|
2022-02-08 02:35:33 +03:00
|
|
|
|`avro_ocf` |Avro object container file |<sub></sub>|
|
2022-01-13 20:34:59 +03:00
|
|
|
|`bencode` |BitTorrent bencoding |<sub></sub>|
|
|
|
|
|`bsd_loopback_frame` |BSD loopback frame |<sub>`ipv4_packet`</sub>|
|
|
|
|
|[`bson`](#bson) |Binary JSON |<sub></sub>|
|
|
|
|
|`bzip2` |bzip2 compression |<sub>`probe`</sub>|
|
|
|
|
|[`cbor`](#cbor) |Concise Binary Object Representation |<sub></sub>|
|
|
|
|
|`dns` |DNS packet |<sub></sub>|
|
|
|
|
|`dns_tcp` |DNS packet (TCP) |<sub></sub>|
|
|
|
|
|`elf` |Executable and Linkable Format |<sub></sub>|
|
|
|
|
|`ether8023_frame` |Ethernet 802.3 frame |<sub>`ipv4_packet`</sub>|
|
|
|
|
|`exif` |Exchangeable Image File Format |<sub></sub>|
|
|
|
|
|`flac` |Free Lossless Audio Codec file |<sub>`flac_metadatablocks` `flac_frame`</sub>|
|
|
|
|
|`flac_frame` |FLAC frame |<sub></sub>|
|
|
|
|
|`flac_metadatablock` |FLAC metadatablock |<sub>`flac_streaminfo` `flac_picture` `vorbis_comment`</sub>|
|
|
|
|
|`flac_metadatablocks` |FLAC metadatablocks |<sub>`flac_metadatablock`</sub>|
|
|
|
|
|`flac_picture` |FLAC metadatablock picture |<sub>`image`</sub>|
|
|
|
|
|`flac_streaminfo` |FLAC streaminfo |<sub></sub>|
|
|
|
|
|`gif` |Graphics Interchange Format |<sub></sub>|
|
|
|
|
|`gzip` |gzip compression |<sub>`probe`</sub>|
|
|
|
|
|`hevc_annexb` |H.265/HEVC Annex B |<sub>`hevc_nalu`</sub>|
|
|
|
|
|`hevc_au` |H.265/HEVC Access Unit |<sub>`hevc_nalu`</sub>|
|
|
|
|
|`hevc_dcr` |H.265/HEVC Decoder Configuration Record |<sub>`hevc_nalu`</sub>|
|
|
|
|
|`hevc_nalu` |H.265/HEVC Network Access Layer Unit |<sub></sub>|
|
|
|
|
|`icc_profile` |International Color Consortium profile |<sub></sub>|
|
|
|
|
|`icmp` |Internet Control Message Protocol |<sub></sub>|
|
|
|
|
|`id3v1` |ID3v1 metadata |<sub></sub>|
|
|
|
|
|`id3v11` |ID3v1.1 metadata |<sub></sub>|
|
|
|
|
|`id3v2` |ID3v2 metadata |<sub>`image`</sub>|
|
|
|
|
|`ipv4_packet` |Internet protocol v4 packet |<sub>`udp_datagram` `tcp_segment` `icmp`</sub>|
|
|
|
|
|`jpeg` |Joint Photographic Experts Group file |<sub>`exif` `icc_profile`</sub>|
|
|
|
|
|`json` |JSON |<sub></sub>|
|
|
|
|
|[`matroska`](#matroska) |Matroska file |<sub>`aac_frame` `av1_ccr` `av1_frame` `avc_au` `avc_dcr` `flac_frame` `flac_metadatablocks` `hevc_au` `hevc_dcr` `image` `mp3_frame` `mpeg_asc` `mpeg_pes_packet` `mpeg_spu` `opus_packet` `vorbis_packet` `vp8_frame` `vp9_cfm` `vp9_frame`</sub>|
|
|
|
|
|`mp3` |MP3 file |<sub>`id3v2` `id3v1` `id3v11` `apev2` `mp3_frame`</sub>|
|
|
|
|
|`mp3_frame` |MPEG audio layer 3 frame |<sub>`xing`</sub>|
|
|
|
|
|[`mp4`](#mp4) |MPEG-4 file and similar |<sub>`aac_frame` `av1_ccr` `av1_frame` `flac_frame` `flac_metadatablocks` `id3v2` `image` `jpeg` `mp3_frame` `avc_au` `avc_dcr` `mpeg_es` `hevc_au` `hevc_dcr` `mpeg_pes_packet` `opus_packet` `protobuf_widevine` `pssh_playready` `vorbis_packet` `vp9_frame` `vpx_ccr`</sub>|
|
|
|
|
|`mpeg_asc` |MPEG-4 Audio Specific Config |<sub></sub>|
|
|
|
|
|`mpeg_es` |MPEG Elementary Stream |<sub>`mpeg_asc` `vorbis_packet`</sub>|
|
|
|
|
|`mpeg_pes` |MPEG Packetized elementary stream |<sub>`mpeg_pes_packet` `mpeg_spu`</sub>|
|
|
|
|
|`mpeg_pes_packet` |MPEG Packetized elementary stream packet |<sub></sub>|
|
|
|
|
|`mpeg_spu` |Sub Picture Unit (DVD subtitle) |<sub></sub>|
|
|
|
|
|`mpeg_ts` |MPEG Transport Stream |<sub></sub>|
|
|
|
|
|[`msgpack`](#msgpack) |MessagePack |<sub></sub>|
|
|
|
|
|`ogg` |OGG file |<sub>`ogg_page` `vorbis_packet` `opus_packet` `flac_metadatablock` `flac_frame`</sub>|
|
|
|
|
|`ogg_page` |OGG page |<sub></sub>|
|
|
|
|
|`opus_packet` |Opus packet |<sub>`vorbis_comment`</sub>|
|
|
|
|
|`pcap` |PCAP packet capture |<sub>`link_frame` `tcp_stream` `ipv4_packet`</sub>|
|
|
|
|
|`pcapng` |PCAPNG packet capture |<sub>`link_frame` `tcp_stream` `ipv4_packet`</sub>|
|
|
|
|
|`png` |Portable Network Graphics file |<sub>`icc_profile` `exif`</sub>|
|
|
|
|
|[`protobuf`](#protobuf) |Protobuf |<sub></sub>|
|
|
|
|
|`protobuf_widevine` |Widevine protobuf |<sub>`protobuf`</sub>|
|
|
|
|
|`pssh_playready` |PlayReady PSSH |<sub></sub>|
|
|
|
|
|`raw` |Raw bits |<sub></sub>|
|
|
|
|
|`sll2_packet` |Linux cooked capture encapsulation v2 |<sub>`ether8023_frame`</sub>|
|
|
|
|
|`sll_packet` |Linux cooked capture encapsulation |<sub>`ether8023_frame`</sub>|
|
|
|
|
|`tar` |Tar archive |<sub>`probe`</sub>|
|
|
|
|
|`tcp_segment` |Transmission control protocol segment |<sub></sub>|
|
|
|
|
|`tiff` |Tag Image File Format |<sub>`icc_profile`</sub>|
|
|
|
|
|`udp_datagram` |User datagram protocol |<sub>`udp_payload`</sub>|
|
|
|
|
|`vorbis_comment` |Vorbis comment |<sub>`flac_picture`</sub>|
|
|
|
|
|`vorbis_packet` |Vorbis packet |<sub>`vorbis_comment`</sub>|
|
|
|
|
|`vp8_frame` |VP8 frame |<sub></sub>|
|
|
|
|
|`vp9_cfm` |VP9 Codec Feature Metadata |<sub></sub>|
|
|
|
|
|`vp9_frame` |VP9 frame |<sub></sub>|
|
|
|
|
|`vpx_ccr` |VPX Codec Configuration Record |<sub></sub>|
|
|
|
|
|`wav` |WAV file |<sub>`id3v2` `id3v1` `id3v11`</sub>|
|
|
|
|
|`webp` |WebP image |<sub>`vp8_frame`</sub>|
|
|
|
|
|`xing` |Xing header |<sub></sub>|
|
|
|
|
|`zip` |ZIP archive |<sub>`probe`</sub>|
|
|
|
|
|`image` |Group |<sub>`gif` `jpeg` `mp4` `png` `tiff` `webp`</sub>|
|
|
|
|
|`link_frame` |Group |<sub>`bsd_loopback_frame` `ether8023_frame` `sll2_packet` `sll_packet`</sub>|
|
2022-02-08 02:35:33 +03:00
|
|
|
|`probe` |Group |<sub>`adts` `ar` `avro_ocf` `bzip2` `elf` `flac` `gif` `gzip` `jpeg` `json` `matroska` `mp3` `mp4` `mpeg_ts` `ogg` `pcap` `pcapng` `png` `tar` `tiff` `wav` `webp` `zip`</sub>|
|
2022-01-13 20:34:59 +03:00
|
|
|
|`tcp_stream` |Group |<sub>`dns`</sub>|
|
|
|
|
|`udp_payload` |Group |<sub>`dns`</sub>|
|
2021-09-19 11:27:56 +03:00
|
|
|
|
|
|
|
[#]: sh-end
|
|
|
|
|
2022-02-05 20:15:18 +03:00
|
|
|
## Format options
|
|
|
|
|
|
|
|
Currently the only option is `force` and is used to ignore some format assertion errors. It can be used as a decode option or as a CLI `-o` option:
|
|
|
|
|
|
|
|
```
|
|
|
|
fq -d mp4 -o force=true file.mp4
|
|
|
|
fq -d raw 'mp4({force: true})' file.mp4
|
|
|
|
```
|
|
|
|
|
|
|
|
## Format functions
|
2022-01-29 14:01:36 +03:00
|
|
|
|
|
|
|
[./formats_collect.sh]: sh-start
|
|
|
|
|
2022-01-13 20:34:59 +03:00
|
|
|
### asn1_ber
|
|
|
|
|
|
|
|
Can also decode CER and BER but with no extra validation. Currently does not support specifying a schema.
|
|
|
|
|
|
|
|
Supports `torepr` but without schema support it's not that useful:
|
|
|
|
|
|
|
|
```
|
|
|
|
fq -d asn1_ber torepr file.ber
|
|
|
|
```
|
|
|
|
|
2022-02-07 19:41:05 +03:00
|
|
|
There is also `frompem` and `topem` to help working with PEM format:
|
|
|
|
|
|
|
|
```
|
|
|
|
fq -d raw 'frompem | asn1_ber | d' cert.pem
|
|
|
|
```
|
|
|
|
|
|
|
|
If the schema is known and not that complicated it can be reproduced:
|
|
|
|
|
|
|
|
```
|
|
|
|
fq -d asn1_ber 'torepr as $r | ["version", "modulus", "private_exponent", "private_exponen", "prime1", "prime2", "exponent1", "exponent2", "coefficient"] | with_entries({key: .value, value: $r[.key]})' pkcs1.der
|
|
|
|
```
|
2022-01-13 20:34:59 +03:00
|
|
|
### becode
|
2022-01-29 14:01:36 +03:00
|
|
|
|
2022-02-01 18:07:41 +03:00
|
|
|
Supports `torepr`:
|
2022-01-29 14:01:36 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
fq -d bencode torepr file.torrent
|
|
|
|
```
|
2022-01-13 20:34:59 +03:00
|
|
|
|
2022-01-29 14:01:36 +03:00
|
|
|
### bson
|
|
|
|
|
2022-02-01 18:07:41 +03:00
|
|
|
Supports `torepr`:
|
2022-01-29 14:01:36 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
fq -d bson torepr file.bson
|
|
|
|
```
|
2022-01-13 20:34:59 +03:00
|
|
|
|
2022-01-29 14:01:36 +03:00
|
|
|
### cbor
|
|
|
|
|
2022-02-01 18:07:41 +03:00
|
|
|
Supports `torepr`:
|
2022-01-29 14:01:36 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
fq -d cbor torepr file.cbor
|
|
|
|
fq -d cbor 'torepr.field' file.cbor
|
|
|
|
fq -d cbor 'torepr | .field' file.cbor
|
|
|
|
fq -d cbor 'torepr | grep("abc")' file.cbor
|
|
|
|
```
|
2022-01-13 20:34:59 +03:00
|
|
|
|
2022-01-29 14:01:36 +03:00
|
|
|
### matroska
|
|
|
|
|
2022-02-01 18:07:41 +03:00
|
|
|
Supports `matroska_path`:
|
2022-01-29 14:01:36 +03:00
|
|
|
|
|
|
|
```
|
2022-02-01 18:07:41 +03:00
|
|
|
$ fq 'matroska_path(".Segment.Tracks[0]")' file.mkv
|
2022-01-29 14:01:36 +03:00
|
|
|
│00 01 02 03 04 05 06 07 08 09│0123456789│.elements[1].elements[3]{}:
|
|
|
|
0x122│ 16 54 ae 6b │ .T.k │ id: "Tracks" (0x1654ae6b) (A Top-Level Element of information with many tracks described.)
|
|
|
|
│ │ │ type: "master" (7)
|
|
|
|
0x122│ 4d bf │ M. │ size: 3519
|
|
|
|
0x122│ bf│ .│ elements[0:3]:
|
|
|
|
0x12c│84 cf 8b db a0 ae 01 00 00 00│..........│
|
|
|
|
0x136│00 00 00 78 d7 81 01 73 c5 88│...x...s..│
|
|
|
|
* │until 0xee9.7 (3519) │ │
|
|
|
|
```
|
|
|
|
|
|
|
|
```
|
2022-01-29 14:20:47 +03:00
|
|
|
$ fq 'first(grep_by(.id == "Tracks")) | matroska_path' test.mkv
|
2022-01-29 14:01:36 +03:00
|
|
|
".Segment.Tracks"
|
|
|
|
```
|
2022-01-13 20:34:59 +03:00
|
|
|
|
2022-01-29 14:01:36 +03:00
|
|
|
### mp4
|
|
|
|
|
2022-02-01 18:07:41 +03:00
|
|
|
Supports `mp4_path`:
|
2022-01-29 14:01:36 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
$ fq 'mp4_path(".moov.trak[1]")' file.mp4
|
|
|
|
│00 01 02 03 04 05 06 07 08 09│0123456789│.boxes[3].boxes[1]{}:
|
|
|
|
0x4f6│ 00 00 02│ ...│ size: 573
|
|
|
|
0x500│3d │= │
|
|
|
|
0x500│ 74 72 61 6b │ trak │ type: "trak" (Container for an individual track or stream)
|
|
|
|
0x500│ 00 00 00 5c 74│ ...\t│ boxes[0:3]:
|
|
|
|
0x50a│6b 68 64 00 00 00 03 00 00 00│khd.......│
|
|
|
|
0x514│00 00 00 00 00 00 00 00 01 00│..........│
|
|
|
|
* │until 0x739.7 (565) │ │
|
|
|
|
```
|
|
|
|
|
|
|
|
```
|
|
|
|
$ fq 'first(grep_by(.type == "trak")) | mp4_path' file.mp4
|
|
|
|
".moov.trak"
|
|
|
|
```
|
2022-01-13 20:34:59 +03:00
|
|
|
|
2022-01-29 14:01:36 +03:00
|
|
|
### msgpack
|
|
|
|
|
2022-02-01 18:07:41 +03:00
|
|
|
Supports `torepr`:
|
2022-01-29 14:01:36 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
fq -d msgpack torepr file.msgpack
|
|
|
|
```
|
2022-01-13 20:34:59 +03:00
|
|
|
|
2022-02-01 18:07:41 +03:00
|
|
|
### protobuf
|
|
|
|
|
|
|
|
`protobuf` decoder can be used to decode sub messages:
|
|
|
|
|
|
|
|
```
|
|
|
|
fq -d protobuf '.fields[6].wire_value | protobuf | d'
|
|
|
|
```
|
2022-01-29 14:01:36 +03:00
|
|
|
|
2022-01-13 20:34:59 +03:00
|
|
|
|
2022-01-29 14:01:36 +03:00
|
|
|
[#]: sh-end
|
|
|
|
|
2021-09-19 11:27:56 +03:00
|
|
|
|
2022-02-05 20:15:18 +03:00
|
|
|
## Dependency graph
|
2021-09-19 11:27:56 +03:00
|
|
|
|
|
|
|
![alt text](formats.svg "Format diagram")
|