2020-06-08 03:29:51 +03:00
|
|
|
|
# TODO: various gojq fq fork regression tests, should probably be move to fork code instead
|
2022-02-12 15:03:38 +03:00
|
|
|
|
# 0xf_ffff_ffff_fffff_fffff-1 | toradix(2,8,16)
|
|
|
|
|
$ fq -n '0b1111111111111111111111111111111111111111111111111111111111111111111111111110, 0o17777777777777777777777776, 0xffffffffffffffffffe'
|
|
|
|
|
75557863725914323419134
|
|
|
|
|
75557863725914323419134
|
|
|
|
|
75557863725914323419134
|
2021-09-06 16:37:55 +03:00
|
|
|
|
$ fq -n '[true] | all'
|
|
|
|
|
true
|
2021-08-13 17:40:28 +03:00
|
|
|
|
$ fq -n '{a:1, b: 2} | tostream'
|
2020-06-08 03:29:51 +03:00
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
"a"
|
|
|
|
|
],
|
|
|
|
|
1
|
|
|
|
|
]
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
"b"
|
|
|
|
|
],
|
|
|
|
|
2
|
|
|
|
|
]
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
"b"
|
|
|
|
|
]
|
|
|
|
|
]
|
2022-05-21 20:33:52 +03:00
|
|
|
|
$ fq -d mp3 '{(.headers[0].magic): 123}' test.mp3
|
2020-06-08 03:29:51 +03:00
|
|
|
|
{
|
|
|
|
|
"ID3": 123
|
|
|
|
|
}
|
2022-05-21 20:33:52 +03:00
|
|
|
|
$ fq -d mp3 '{(.headers[0].magic): 123}' test.mp3
|
2020-06-08 03:29:51 +03:00
|
|
|
|
{
|
|
|
|
|
"ID3": 123
|
|
|
|
|
}
|
2022-05-21 20:33:52 +03:00
|
|
|
|
$ fq -d mp3 '.frames | group_by(.side_info | {b: .main_data_end}) | map(length)' test.mp3
|
2020-06-08 03:29:51 +03:00
|
|
|
|
[
|
|
|
|
|
2,
|
|
|
|
|
1
|
|
|
|
|
]
|
2022-05-21 20:33:52 +03:00
|
|
|
|
$ fq -d mp3 '.frames | map(.header) | group_by(.bitrate)' test.mp3
|
2020-06-08 03:29:51 +03:00
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
"bitrate": 56000,
|
2022-04-05 14:57:55 +03:00
|
|
|
|
"channel_mode": "none",
|
|
|
|
|
"channels": "mono",
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"copyright": 0,
|
2022-04-05 14:57:55 +03:00
|
|
|
|
"emphasis": "none",
|
2021-11-05 17:04:26 +03:00
|
|
|
|
"layer": 3,
|
|
|
|
|
"mpeg_version": "1",
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"original": 0,
|
2022-04-05 14:57:55 +03:00
|
|
|
|
"padding": "not_padded",
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"private": 0,
|
2021-11-05 17:04:26 +03:00
|
|
|
|
"protection_absent": true,
|
2021-09-20 19:54:06 +03:00
|
|
|
|
"sample_count": 1152,
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"sample_rate": 44100,
|
2021-11-05 17:04:26 +03:00
|
|
|
|
"sync": 2047
|
2020-06-08 03:29:51 +03:00
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
"bitrate": 64000,
|
2022-04-05 14:57:55 +03:00
|
|
|
|
"channel_mode": "none",
|
|
|
|
|
"channels": "mono",
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"copyright": 0,
|
2022-04-05 14:57:55 +03:00
|
|
|
|
"emphasis": "none",
|
2021-11-05 17:04:26 +03:00
|
|
|
|
"layer": 3,
|
|
|
|
|
"mpeg_version": "1",
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"original": 1,
|
2022-04-05 14:57:55 +03:00
|
|
|
|
"padding": "not_padded",
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"private": 0,
|
2021-11-05 17:04:26 +03:00
|
|
|
|
"protection_absent": true,
|
2021-09-20 19:54:06 +03:00
|
|
|
|
"sample_count": 1152,
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"sample_rate": 44100,
|
2021-11-05 17:04:26 +03:00
|
|
|
|
"sync": 2047
|
2020-06-08 03:29:51 +03:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"bitrate": 64000,
|
2022-04-05 14:57:55 +03:00
|
|
|
|
"channel_mode": "none",
|
|
|
|
|
"channels": "mono",
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"copyright": 0,
|
2022-04-05 14:57:55 +03:00
|
|
|
|
"emphasis": "none",
|
2021-11-05 17:04:26 +03:00
|
|
|
|
"layer": 3,
|
|
|
|
|
"mpeg_version": "1",
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"original": 1,
|
2022-04-05 14:57:55 +03:00
|
|
|
|
"padding": "padded",
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"private": 0,
|
2021-11-05 17:04:26 +03:00
|
|
|
|
"protection_absent": true,
|
2021-09-20 19:54:06 +03:00
|
|
|
|
"sample_count": 1152,
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"sample_rate": 44100,
|
2021-11-05 17:04:26 +03:00
|
|
|
|
"sync": 2047
|
2020-06-08 03:29:51 +03:00
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
]
|
2022-05-21 20:33:52 +03:00
|
|
|
|
$ fq -d mp3 '.frames | map(.header) | sort_by(.bitrate)' test.mp3
|
2020-06-08 03:29:51 +03:00
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
"bitrate": 56000,
|
2022-04-05 14:57:55 +03:00
|
|
|
|
"channel_mode": "none",
|
|
|
|
|
"channels": "mono",
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"copyright": 0,
|
2022-04-05 14:57:55 +03:00
|
|
|
|
"emphasis": "none",
|
2021-11-05 17:04:26 +03:00
|
|
|
|
"layer": 3,
|
|
|
|
|
"mpeg_version": "1",
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"original": 0,
|
2022-04-05 14:57:55 +03:00
|
|
|
|
"padding": "not_padded",
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"private": 0,
|
2021-11-05 17:04:26 +03:00
|
|
|
|
"protection_absent": true,
|
2021-09-20 19:54:06 +03:00
|
|
|
|
"sample_count": 1152,
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"sample_rate": 44100,
|
2021-11-05 17:04:26 +03:00
|
|
|
|
"sync": 2047
|
2020-06-08 03:29:51 +03:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"bitrate": 64000,
|
2022-04-05 14:57:55 +03:00
|
|
|
|
"channel_mode": "none",
|
|
|
|
|
"channels": "mono",
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"copyright": 0,
|
2022-04-05 14:57:55 +03:00
|
|
|
|
"emphasis": "none",
|
2021-11-05 17:04:26 +03:00
|
|
|
|
"layer": 3,
|
|
|
|
|
"mpeg_version": "1",
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"original": 1,
|
2022-04-05 14:57:55 +03:00
|
|
|
|
"padding": "not_padded",
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"private": 0,
|
2021-11-05 17:04:26 +03:00
|
|
|
|
"protection_absent": true,
|
2021-09-20 19:54:06 +03:00
|
|
|
|
"sample_count": 1152,
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"sample_rate": 44100,
|
2021-11-05 17:04:26 +03:00
|
|
|
|
"sync": 2047
|
2020-06-08 03:29:51 +03:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"bitrate": 64000,
|
2022-04-05 14:57:55 +03:00
|
|
|
|
"channel_mode": "none",
|
|
|
|
|
"channels": "mono",
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"copyright": 0,
|
2022-04-05 14:57:55 +03:00
|
|
|
|
"emphasis": "none",
|
2021-11-05 17:04:26 +03:00
|
|
|
|
"layer": 3,
|
|
|
|
|
"mpeg_version": "1",
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"original": 1,
|
2022-04-05 14:57:55 +03:00
|
|
|
|
"padding": "padded",
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"private": 0,
|
2021-11-05 17:04:26 +03:00
|
|
|
|
"protection_absent": true,
|
2021-09-20 19:54:06 +03:00
|
|
|
|
"sample_count": 1152,
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"sample_rate": 44100,
|
2021-11-05 17:04:26 +03:00
|
|
|
|
"sync": 2047
|
2020-06-08 03:29:51 +03:00
|
|
|
|
}
|
|
|
|
|
]
|
2022-05-21 20:33:52 +03:00
|
|
|
|
$ fq -d mp3 '.frames | map(.header) | sort_by(.bitrate)[0]' test.mp3
|
2022-05-20 13:38:43 +03:00
|
|
|
|
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.frames[0].header{}:
|
2021-11-05 17:04:26 +03:00
|
|
|
|
0x20| ff fb | .. | sync: 0b11111111111 (valid)
|
|
|
|
|
0x20| fb | . | mpeg_version: "1" (3) (MPEG Version 1)
|
|
|
|
|
0x20| fb | . | layer: 3 (1) (MPEG Layer 3)
|
2021-09-20 19:54:06 +03:00
|
|
|
|
| | | sample_count: 1152
|
2021-11-05 17:04:26 +03:00
|
|
|
|
0x20| fb | . | protection_absent: true (No CRC)
|
|
|
|
|
0x20| 40| @| bitrate: 56000 (4)
|
|
|
|
|
0x20| 40| @| sample_rate: 44100 (0)
|
2022-04-05 14:57:55 +03:00
|
|
|
|
0x20| 40| @| padding: "not_padded" (0b0)
|
2020-06-08 03:29:51 +03:00
|
|
|
|
0x20| 40| @| private: 0
|
2022-04-05 14:57:55 +03:00
|
|
|
|
0x30|c0 |. | channels: "mono" (0b11)
|
|
|
|
|
0x30|c0 |. | channel_mode: "none" (0b0)
|
2020-06-08 03:29:51 +03:00
|
|
|
|
0x30|c0 |. | copyright: 0
|
|
|
|
|
0x30|c0 |. | original: 0
|
2022-04-05 14:57:55 +03:00
|
|
|
|
0x30|c0 |. | emphasis: "none" (0b0)
|
2022-05-21 20:33:52 +03:00
|
|
|
|
$ fq -d mp3 '.frames | map(.header) | min_by(.bitrate)' test.mp3
|
2022-05-20 13:38:43 +03:00
|
|
|
|
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.frames[0].header{}:
|
2021-11-05 17:04:26 +03:00
|
|
|
|
0x20| ff fb | .. | sync: 0b11111111111 (valid)
|
|
|
|
|
0x20| fb | . | mpeg_version: "1" (3) (MPEG Version 1)
|
|
|
|
|
0x20| fb | . | layer: 3 (1) (MPEG Layer 3)
|
2021-09-20 19:54:06 +03:00
|
|
|
|
| | | sample_count: 1152
|
2021-11-05 17:04:26 +03:00
|
|
|
|
0x20| fb | . | protection_absent: true (No CRC)
|
|
|
|
|
0x20| 40| @| bitrate: 56000 (4)
|
|
|
|
|
0x20| 40| @| sample_rate: 44100 (0)
|
2022-04-05 14:57:55 +03:00
|
|
|
|
0x20| 40| @| padding: "not_padded" (0b0)
|
2020-06-08 03:29:51 +03:00
|
|
|
|
0x20| 40| @| private: 0
|
2022-04-05 14:57:55 +03:00
|
|
|
|
0x30|c0 |. | channels: "mono" (0b11)
|
|
|
|
|
0x30|c0 |. | channel_mode: "none" (0b0)
|
2020-06-08 03:29:51 +03:00
|
|
|
|
0x30|c0 |. | copyright: 0
|
|
|
|
|
0x30|c0 |. | original: 0
|
2022-04-05 14:57:55 +03:00
|
|
|
|
0x30|c0 |. | emphasis: "none" (0b0)
|
2022-05-21 20:33:52 +03:00
|
|
|
|
$ fq -d mp3 '.frames | map(.header) | max_by(.bitrate)' test.mp3
|
2022-05-20 13:38:43 +03:00
|
|
|
|
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.frames[2].header{}:
|
2021-11-05 17:04:26 +03:00
|
|
|
|
0x1b0| ff fb | .. | sync: 0b11111111111 (valid)
|
|
|
|
|
0x1b0| fb | . | mpeg_version: "1" (3) (MPEG Version 1)
|
|
|
|
|
0x1b0| fb | . | layer: 3 (1) (MPEG Layer 3)
|
2021-09-20 19:54:06 +03:00
|
|
|
|
| | | sample_count: 1152
|
2021-11-05 17:04:26 +03:00
|
|
|
|
0x1b0| fb | . | protection_absent: true (No CRC)
|
|
|
|
|
0x1b0| 52 | R | bitrate: 64000 (5)
|
|
|
|
|
0x1b0| 52 | R | sample_rate: 44100 (0)
|
2022-04-05 14:57:55 +03:00
|
|
|
|
0x1b0| 52 | R | padding: "padded" (0b1)
|
2020-06-08 03:29:51 +03:00
|
|
|
|
0x1b0| 52 | R | private: 0
|
2022-04-05 14:57:55 +03:00
|
|
|
|
0x1b0| c4 | . | channels: "mono" (0b11)
|
|
|
|
|
0x1b0| c4 | . | channel_mode: "none" (0b0)
|
2020-06-08 03:29:51 +03:00
|
|
|
|
0x1b0| c4 | . | copyright: 0
|
|
|
|
|
0x1b0| c4 | . | original: 1
|
2022-04-05 14:57:55 +03:00
|
|
|
|
0x1b0| c4 | . | emphasis: "none" (0b0)
|
2022-05-21 20:33:52 +03:00
|
|
|
|
$ fq -d mp3 '.frames[0] | . + .header | keys, .bitrate' test.mp3
|
2020-06-08 03:29:51 +03:00
|
|
|
|
[
|
|
|
|
|
"bitrate",
|
|
|
|
|
"channel_mode",
|
|
|
|
|
"channels",
|
|
|
|
|
"copyright",
|
|
|
|
|
"crc_calculated",
|
|
|
|
|
"emphasis",
|
|
|
|
|
"header",
|
|
|
|
|
"layer",
|
|
|
|
|
"mpeg_version",
|
|
|
|
|
"original",
|
|
|
|
|
"padding",
|
|
|
|
|
"private",
|
2021-11-05 17:04:26 +03:00
|
|
|
|
"protection_absent",
|
2021-09-20 19:54:06 +03:00
|
|
|
|
"sample_count",
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"sample_rate",
|
|
|
|
|
"side_info",
|
|
|
|
|
"sync",
|
|
|
|
|
"xing"
|
|
|
|
|
]
|
2022-05-20 13:38:43 +03:00
|
|
|
|
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
|
2021-11-05 17:04:26 +03:00
|
|
|
|
0x20| 40| @|.frames[0].header.bitrate: 56000 (4)
|
2022-05-21 20:33:52 +03:00
|
|
|
|
$ fq -d mp3 '[.frames[0] | ., .header] | add | keys, .bitrate' test.mp3
|
2020-06-08 03:29:51 +03:00
|
|
|
|
[
|
|
|
|
|
"bitrate",
|
|
|
|
|
"channel_mode",
|
|
|
|
|
"channels",
|
|
|
|
|
"copyright",
|
|
|
|
|
"crc_calculated",
|
|
|
|
|
"emphasis",
|
|
|
|
|
"header",
|
|
|
|
|
"layer",
|
|
|
|
|
"mpeg_version",
|
|
|
|
|
"original",
|
|
|
|
|
"padding",
|
|
|
|
|
"private",
|
2021-11-05 17:04:26 +03:00
|
|
|
|
"protection_absent",
|
2021-09-20 19:54:06 +03:00
|
|
|
|
"sample_count",
|
2020-06-08 03:29:51 +03:00
|
|
|
|
"sample_rate",
|
|
|
|
|
"side_info",
|
|
|
|
|
"sync",
|
|
|
|
|
"xing"
|
|
|
|
|
]
|
2022-05-20 13:38:43 +03:00
|
|
|
|
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
|
2021-11-05 17:04:26 +03:00
|
|
|
|
0x20| 40| @|.frames[0].header.bitrate: 56000 (4)
|
2022-07-26 16:50:18 +03:00
|
|
|
|
# make sure to_entries preserve struct order
|
|
|
|
|
$ fq -d mp3 '.frames[0] | keys' test.mp3
|
|
|
|
|
[
|
|
|
|
|
"header",
|
|
|
|
|
"side_info",
|
|
|
|
|
"xing",
|
|
|
|
|
"padding",
|
|
|
|
|
"crc_calculated"
|
|
|
|
|
]
|
|
|
|
|
$ fq -d mp3 '.frames[0] | to_entries[].key' test.mp3
|
|
|
|
|
"header"
|
|
|
|
|
"side_info"
|
|
|
|
|
"xing"
|
|
|
|
|
"padding"
|
|
|
|
|
"crc_calculated"
|
2022-07-26 18:43:59 +03:00
|
|
|
|
# xml, csv does string normalization, make sure it works with nested JQValue:s
|
|
|
|
|
# TODO: move this test as it depends on xml
|
|
|
|
|
$ fq -r '.headers[0] | toxml({indent: 2})' test.mp3
|
|
|
|
|
<doc>
|
|
|
|
|
<flags>
|
|
|
|
|
<experimental_indicator>false</experimental_indicator>
|
|
|
|
|
<extended_header>false</extended_header>
|
|
|
|
|
<unsynchronisation>false</unsynchronisation>
|
|
|
|
|
<unused>0</unused>
|
|
|
|
|
</flags>
|
|
|
|
|
<frames>
|
|
|
|
|
<flags>
|
|
|
|
|
<compression>false</compression>
|
|
|
|
|
<data_length_indicator>false</data_length_indicator>
|
|
|
|
|
<encryption>false</encryption>
|
|
|
|
|
<file_alter_preservation>false</file_alter_preservation>
|
|
|
|
|
<grouping_identity>false</grouping_identity>
|
|
|
|
|
<read_only>false</read_only>
|
|
|
|
|
<tag_alter_preservation>false</tag_alter_preservation>
|
|
|
|
|
<unsync>false</unsync>
|
|
|
|
|
<unused0>0</unused0>
|
|
|
|
|
<unused1>0</unused1>
|
|
|
|
|
<unused2>0</unused2>
|
|
|
|
|
</flags>
|
|
|
|
|
<id>TSSE</id>
|
|
|
|
|
<size>15</size>
|
|
|
|
|
<text>Lavf58.45.100</text>
|
|
|
|
|
<text_encoding>utf8</text_encoding>
|
|
|
|
|
</frames>
|
|
|
|
|
<magic>ID3</magic>
|
|
|
|
|
<padding><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></padding>
|
|
|
|
|
<revision>0</revision>
|
|
|
|
|
<size>35</size>
|
|
|
|
|
<version>4</version>
|
|
|
|
|
</doc>
|