2020-06-08 03:29:51 +03:00
|
|
|
# TODO: various gojq fq fork regression tests, should probably be move to fork code instead
|
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"
|
|
|
|
]
|
|
|
|
]
|
2021-08-13 17:40:28 +03:00
|
|
|
$ fq -d mp3 '{(.headers[0].magic): 123}' /test.mp3
|
2020-06-08 03:29:51 +03:00
|
|
|
{
|
|
|
|
"ID3": 123
|
|
|
|
}
|
2021-08-13 17:40:28 +03:00
|
|
|
$ fq -d mp3 '{(.headers[0].magic): 123}' /test.mp3
|
2020-06-08 03:29:51 +03:00
|
|
|
{
|
|
|
|
"ID3": 123
|
|
|
|
}
|
2021-08-13 17:40:28 +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
|
|
|
|
]
|
2021-08-13 17:40:28 +03:00
|
|
|
$ fq -d mp3 '.frames | map(.header) | group_by(.bitrate)' /test.mp3
|
2020-06-08 03:29:51 +03:00
|
|
|
[
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"bitrate": 56000,
|
2021-11-05 19:24:49 +03:00
|
|
|
"channel_mode": "None",
|
|
|
|
"channels": "Mono",
|
2020-06-08 03:29:51 +03:00
|
|
|
"copyright": 0,
|
2021-11-05 19:24:49 +03:00
|
|
|
"emphasis": "None",
|
|
|
|
"layer": "Layer 3",
|
|
|
|
"mpeg_version": "MPEG Version 1",
|
2020-06-08 03:29:51 +03:00
|
|
|
"original": 0,
|
2021-11-05 19:24:49 +03:00
|
|
|
"padding": "Not padded",
|
2020-06-08 03:29:51 +03:00
|
|
|
"private": 0,
|
2021-11-05 19:24:49 +03:00
|
|
|
"protection": "Not protected",
|
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 19:24:49 +03:00
|
|
|
"sync": "Correct"
|
2020-06-08 03:29:51 +03:00
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"bitrate": 64000,
|
2021-11-05 19:24:49 +03:00
|
|
|
"channel_mode": "None",
|
|
|
|
"channels": "Mono",
|
2020-06-08 03:29:51 +03:00
|
|
|
"copyright": 0,
|
2021-11-05 19:24:49 +03:00
|
|
|
"emphasis": "None",
|
|
|
|
"layer": "Layer 3",
|
|
|
|
"mpeg_version": "MPEG Version 1",
|
2020-06-08 03:29:51 +03:00
|
|
|
"original": 1,
|
2021-11-05 19:24:49 +03:00
|
|
|
"padding": "Not padded",
|
2020-06-08 03:29:51 +03:00
|
|
|
"private": 0,
|
2021-11-05 19:24:49 +03:00
|
|
|
"protection": "Not protected",
|
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 19:24:49 +03:00
|
|
|
"sync": "Correct"
|
2020-06-08 03:29:51 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"bitrate": 64000,
|
2021-11-05 19:24:49 +03:00
|
|
|
"channel_mode": "None",
|
|
|
|
"channels": "Mono",
|
2020-06-08 03:29:51 +03:00
|
|
|
"copyright": 0,
|
2021-11-05 19:24:49 +03:00
|
|
|
"emphasis": "None",
|
|
|
|
"layer": "Layer 3",
|
|
|
|
"mpeg_version": "MPEG Version 1",
|
2020-06-08 03:29:51 +03:00
|
|
|
"original": 1,
|
2021-11-05 19:24:49 +03:00
|
|
|
"padding": "Padded",
|
2020-06-08 03:29:51 +03:00
|
|
|
"private": 0,
|
2021-11-05 19:24:49 +03:00
|
|
|
"protection": "Not protected",
|
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 19:24:49 +03:00
|
|
|
"sync": "Correct"
|
2020-06-08 03:29:51 +03:00
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
2021-08-13 17:40:28 +03:00
|
|
|
$ fq -d mp3 '.frames | map(.header) | sort_by(.bitrate)' /test.mp3
|
2020-06-08 03:29:51 +03:00
|
|
|
[
|
|
|
|
{
|
|
|
|
"bitrate": 56000,
|
2021-11-05 19:24:49 +03:00
|
|
|
"channel_mode": "None",
|
|
|
|
"channels": "Mono",
|
2020-06-08 03:29:51 +03:00
|
|
|
"copyright": 0,
|
2021-11-05 19:24:49 +03:00
|
|
|
"emphasis": "None",
|
|
|
|
"layer": "Layer 3",
|
|
|
|
"mpeg_version": "MPEG Version 1",
|
2020-06-08 03:29:51 +03:00
|
|
|
"original": 0,
|
2021-11-05 19:24:49 +03:00
|
|
|
"padding": "Not padded",
|
2020-06-08 03:29:51 +03:00
|
|
|
"private": 0,
|
2021-11-05 19:24:49 +03:00
|
|
|
"protection": "Not protected",
|
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 19:24:49 +03:00
|
|
|
"sync": "Correct"
|
2020-06-08 03:29:51 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"bitrate": 64000,
|
2021-11-05 19:24:49 +03:00
|
|
|
"channel_mode": "None",
|
|
|
|
"channels": "Mono",
|
2020-06-08 03:29:51 +03:00
|
|
|
"copyright": 0,
|
2021-11-05 19:24:49 +03:00
|
|
|
"emphasis": "None",
|
|
|
|
"layer": "Layer 3",
|
|
|
|
"mpeg_version": "MPEG Version 1",
|
2020-06-08 03:29:51 +03:00
|
|
|
"original": 1,
|
2021-11-05 19:24:49 +03:00
|
|
|
"padding": "Not padded",
|
2020-06-08 03:29:51 +03:00
|
|
|
"private": 0,
|
2021-11-05 19:24:49 +03:00
|
|
|
"protection": "Not protected",
|
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 19:24:49 +03:00
|
|
|
"sync": "Correct"
|
2020-06-08 03:29:51 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"bitrate": 64000,
|
2021-11-05 19:24:49 +03:00
|
|
|
"channel_mode": "None",
|
|
|
|
"channels": "Mono",
|
2020-06-08 03:29:51 +03:00
|
|
|
"copyright": 0,
|
2021-11-05 19:24:49 +03:00
|
|
|
"emphasis": "None",
|
|
|
|
"layer": "Layer 3",
|
|
|
|
"mpeg_version": "MPEG Version 1",
|
2020-06-08 03:29:51 +03:00
|
|
|
"original": 1,
|
2021-11-05 19:24:49 +03:00
|
|
|
"padding": "Padded",
|
2020-06-08 03:29:51 +03:00
|
|
|
"private": 0,
|
2021-11-05 19:24:49 +03:00
|
|
|
"protection": "Not protected",
|
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 19:24:49 +03:00
|
|
|
"sync": "Correct"
|
2020-06-08 03:29:51 +03:00
|
|
|
}
|
|
|
|
]
|
2021-08-13 17:40:28 +03:00
|
|
|
$ fq -d mp3 '.frames | map(.header) | sort_by(.bitrate)[0]' /test.mp3
|
2021-09-16 23:40:03 +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 19:24:49 +03:00
|
|
|
0x20| ff fb | .. | sync: "Correct" (0x7ff)
|
|
|
|
0x20| fb | . | mpeg_version: "MPEG Version 1" (1)
|
|
|
|
0x20| fb | . | layer: "Layer 3" (3)
|
2021-09-20 19:54:06 +03:00
|
|
|
| | | sample_count: 1152
|
2021-11-05 19:24:49 +03:00
|
|
|
0x20| fb | . | protection: "Not protected" (true)
|
2020-06-08 03:29:51 +03:00
|
|
|
0x20| 40| @| bitrate: 56000
|
|
|
|
0x20| 40| @| sample_rate: 44100
|
2021-11-05 19:24:49 +03:00
|
|
|
0x20| 40| @| padding: "Not padded" (0b0)
|
2020-06-08 03:29:51 +03:00
|
|
|
0x20| 40| @| private: 0
|
2021-11-05 19:24:49 +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
|
2021-11-05 19:24:49 +03:00
|
|
|
0x30|c0 |. | emphasis: "None" (0b0)
|
2021-08-13 17:40:28 +03:00
|
|
|
$ fq -d mp3 '.frames | map(.header) | min_by(.bitrate)' /test.mp3
|
2021-09-16 23:40:03 +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 19:24:49 +03:00
|
|
|
0x20| ff fb | .. | sync: "Correct" (0x7ff)
|
|
|
|
0x20| fb | . | mpeg_version: "MPEG Version 1" (1)
|
|
|
|
0x20| fb | . | layer: "Layer 3" (3)
|
2021-09-20 19:54:06 +03:00
|
|
|
| | | sample_count: 1152
|
2021-11-05 19:24:49 +03:00
|
|
|
0x20| fb | . | protection: "Not protected" (true)
|
2020-06-08 03:29:51 +03:00
|
|
|
0x20| 40| @| bitrate: 56000
|
|
|
|
0x20| 40| @| sample_rate: 44100
|
2021-11-05 19:24:49 +03:00
|
|
|
0x20| 40| @| padding: "Not padded" (0b0)
|
2020-06-08 03:29:51 +03:00
|
|
|
0x20| 40| @| private: 0
|
2021-11-05 19:24:49 +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
|
2021-11-05 19:24:49 +03:00
|
|
|
0x30|c0 |. | emphasis: "None" (0b0)
|
2021-08-13 17:40:28 +03:00
|
|
|
$ fq -d mp3 '.frames | map(.header) | max_by(.bitrate)' /test.mp3
|
2021-09-16 23:40:03 +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 19:24:49 +03:00
|
|
|
0x1b0| ff fb | .. | sync: "Correct" (0x7ff)
|
|
|
|
0x1b0| fb | . | mpeg_version: "MPEG Version 1" (1)
|
|
|
|
0x1b0| fb | . | layer: "Layer 3" (3)
|
2021-09-20 19:54:06 +03:00
|
|
|
| | | sample_count: 1152
|
2021-11-05 19:24:49 +03:00
|
|
|
0x1b0| fb | . | protection: "Not protected" (true)
|
2020-06-08 03:29:51 +03:00
|
|
|
0x1b0| 52 | R | bitrate: 64000
|
|
|
|
0x1b0| 52 | R | sample_rate: 44100
|
2021-11-05 19:24:49 +03:00
|
|
|
0x1b0| 52 | R | padding: "Padded" (0b1)
|
2020-06-08 03:29:51 +03:00
|
|
|
0x1b0| 52 | R | private: 0
|
2021-11-05 19:24:49 +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
|
2021-11-05 19:24:49 +03:00
|
|
|
0x1b0| c4 | . | emphasis: "None" (0b0)
|
2021-08-13 17:40:28 +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",
|
|
|
|
"protection",
|
2021-09-20 19:54:06 +03:00
|
|
|
"sample_count",
|
2020-06-08 03:29:51 +03:00
|
|
|
"sample_rate",
|
|
|
|
"side_info",
|
|
|
|
"sync",
|
|
|
|
"xing"
|
|
|
|
]
|
2021-09-16 23:40:03 +03:00
|
|
|
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
|
2020-06-08 03:29:51 +03:00
|
|
|
0x20| 40| @|.frames[0].header.bitrate: 56000
|
2021-08-13 17:40:28 +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",
|
|
|
|
"protection",
|
2021-09-20 19:54:06 +03:00
|
|
|
"sample_count",
|
2020-06-08 03:29:51 +03:00
|
|
|
"sample_rate",
|
|
|
|
"side_info",
|
|
|
|
"sync",
|
|
|
|
"xing"
|
|
|
|
]
|
2021-09-16 23:40:03 +03:00
|
|
|
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
|
2020-06-08 03:29:51 +03:00
|
|
|
0x20| 40| @|.frames[0].header.bitrate: 56000
|