1
1
mirror of https://github.com/wader/fq.git synced 2024-11-28 03:02:55 +03:00
fq/pkg/interp/testdata/value.fqtest
2021-09-12 13:08:53 +02:00

673 lines
14 KiB
Plaintext

/test.mp3:
# ffmpeg -f lavfi -i sine -t 10ms test.mp3
$ fq -d mp3 '.frames[0].xing | ., .frames, .toc, .header, .present_flags.toc, .missing' /test.mp3
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |.frames[0].xing: {} (xing)
0x40| 49 6e 66 6f | Info | header: "Info"
0x40| 00 00 00 0f | .... | present_flags: {}
0x40| 00 00 00 02 | .... | frames: 2
0x40| 00 00| ..| bytes: 599
0x50|02 57 |.W |
0x50| 00 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6| ..............| toc: [100]
0x60|a6 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6|................|
* |until 0xb5.7 (100) | |
0xb0| 00 00 00 00 | .... | quality: 0
0xb0| 4c 61 76 63 35 38| Lavc58| lame_extension: {}
0xc0|2e 39 31 00 00 00 00 00 00 00 00 00 00 00 00 24|.91............$|
0xd0|05 07 00 00 00 00 00 00 02 57 62 f0 5a 35 |.........Wb.Z5 |
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |
0x40| 00 00 00 02 | .... |.frames[0].xing.frames: 2
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |.frames[0].xing.toc: [100]
0x50| 00 | . | [0]: 0
0x50| a6 | . | [1]: 166
0x50| a6 | . | [2]: 166
0x50| a6 | . | [3]: 166
0x50| a6 | . | [4]: 166
0x50| a6 | . | [5]: 166
0x50| a6 | . | [6]: 166
0x50| a6 | . | [7]: 166
0x50| a6 | . | [8]: 166
0x50| a6 | . | [9]: 166
0x50| a6 | . | [10]: 166
0x50| a6 | . | [11]: 166
0x50| a6 | . | [12]: 166
0x50| a6| .| [13]: 166
0x60|a6 |. | [14]: 166
0x60| a6 | . | [15]: 166
0x60| a6 | . | [16]: 166
0x60| a6 | . | [17]: 166
0x60| a6 | . | [18]: 166
0x60| a6 | . | [19]: 166
0x60| a6 | . | [20]: 166
0x60| a6 | . | [21]: 166
0x60| a6 | . | [22]: 166
0x60| a6 | . | [23]: 166
0x60| a6 | . | [24]: 166
0x60| a6 | . | [25]: 166
0x60| a6 | . | [26]: 166
0x60| a6 | . | [27]: 166
0x60| a6 | . | [28]: 166
0x60| a6| .| [29]: 166
0x70|a6 |. | [30]: 166
0x70| a6 | . | [31]: 166
0x70| a6 | . | [32]: 166
0x70| a6 | . | [33]: 166
0x70| a6 | . | [34]: 166
0x70| a6 | . | [35]: 166
0x70| a6 | . | [36]: 166
0x70| a6 | . | [37]: 166
0x70| a6 | . | [38]: 166
0x70| a6 | . | [39]: 166
0x70| a6 | . | [40]: 166
0x70| a6 | . | [41]: 166
0x70| a6 | . | [42]: 166
0x70| a6 | . | [43]: 166
0x70| a6 | . | [44]: 166
0x70| a6| .| [45]: 166
0x80|a6 |. | [46]: 166
0x80| a6 | . | [47]: 166
0x80| a6 | . | [48]: 166
0x80| a6 | . | [49]: 166
| | | [50:99]: ...
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |
0x40| 49 6e 66 6f | Info |.frames[0].xing.header: "Info"
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |
0x40| 0f | . |.frames[0].xing.present_flags.toc: true
null
$ fq -d mp3 '.frames[0].xing | ., .frames, .toc, .header, .present_flags.toc, .missing | tovalue' /test.mp3
{
"bytes": 599,
"frames": 2,
"header": "Info",
"lame_extension": {
"abr_vbr": 0,
"audiophile_replay_gain": 0,
"encoder": "Lavc58.91",
"encoder_delay": 576,
"encoder_padding": 1287,
"lame_ath_type": 0,
"lame_flags": 0,
"length": 599,
"lowpass_filter": 0,
"misc": 0,
"mp3_gain": 0,
"music_crc": 25328,
"preset": 0,
"radio_replay_gain": 0,
"replay_gain_peak": 0,
"tag_crc": 23093,
"tag_revision": 0,
"vbr_method": 0
},
"present_flags": {
"bytes": true,
"frames": true,
"quality": true,
"toc": true,
"unused": 0
},
"quality": 0,
"toc": [
0,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255
]
}
2
[
0,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255
]
"Info"
true
null
$ fq -d mp3 '.frames[0].xing | ., .frames, .toc, .header, .present_flags.toc, .missing | tovalue' /test.mp3
{
"bytes": 599,
"frames": 2,
"header": "Info",
"lame_extension": {
"abr_vbr": 0,
"audiophile_replay_gain": 0,
"encoder": "Lavc58.91",
"encoder_delay": 576,
"encoder_padding": 1287,
"lame_ath_type": 0,
"lame_flags": 0,
"length": 599,
"lowpass_filter": 0,
"misc": 0,
"mp3_gain": 0,
"music_crc": 25328,
"preset": 0,
"radio_replay_gain": 0,
"replay_gain_peak": 0,
"tag_crc": 23093,
"tag_revision": 0,
"vbr_method": 0
},
"present_flags": {
"bytes": true,
"frames": true,
"quality": true,
"toc": true,
"unused": 0
},
"quality": 0,
"toc": [
0,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255
]
}
2
[
0,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
166,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255
]
"Info"
true
null
$ fq -d mp3 '.frames[0].xing | ., .frames, .toc, .header, .present_flags.toc, .missing | type' /test.mp3
"object"
"number"
"array"
"string"
"boolean"
"null"
$ fq -d mp3 '.headers | length, type' /test.mp3
1
"array"
$ fq -d mp3 '.headers | tostring' /test.mp3
exitcode: 5
stderr:
error: tostring cannot be applied to: array
$ fq -d mp3 '.headers | tonumber' /test.mp3
exitcode: 5
stderr:
error: tonumber cannot be applied to: array
$ fq -d mp3 '.headers[0] | tostring' /test.mp3
exitcode: 5
stderr:
error: tostring cannot be applied to: object
$ fq -d mp3 '.headers[0] | tonumber' /test.mp3
exitcode: 5
stderr:
error: tonumber cannot be applied to: object
$ fq -d mp3 '.headers[0].version | tonumber' /test.mp3
4
$ fq -d mp3 '.headers[0].version | tostring' /test.mp3
"4"
$ fq -d mp3 '.headers[0].magic | tonumber' /test.mp3
exitcode: 5
stderr:
error: invalid number: "ID3"
$ fq -d mp3 '.headers[0].magic | tovalue, length, tostring, type' /test.mp3
"ID3"
3
"ID3"
"string"
$ fq -d mp3 '.headers[0].magic[4]' /test.mp3
""
$ fq -d mp3 '.headers[0].magic[4:10]' /test.mp3
""
$ fq -d mp3 '.headers[10]' /test.mp3
null
$ fq -d mp3 '.headers[10:20]' /test.mp3
[]
$ fq -d mp3 '.headers[0].padding | tovalue, length, tostring, type' /test.mp3
null
0
"null"
"null"
$ fq -d mp3 '.headers[0].flags.unsynchronisation | tovalue, tostring, type' /test.mp3
false
"false"
"boolean"
# regresison null value (padding)
$ fq -d mp3 '.headers[0] | tovalue' /test.mp3
{
"flags": {
"experimental_indicator": false,
"extended_header": false,
"unsynchronisation": false,
"unused": 0
},
"frames": [
{
"flags": {
"compression": false,
"data_length_indicator": false,
"encryption": false,
"file_alter_preservation": false,
"grouping_identity": false,
"read_only": false,
"tag_alter_preservation": false,
"unsync": false,
"unused0": 0,
"unused1": 0,
"unused2": 0
},
"id": "TSSE",
"size": 15,
"text": "Lavf58.45.100",
"text_encoding": 3
}
],
"magic": "ID3",
"padding": null,
"revision": 0,
"size": 35,
"version": 4
}
# test each in decoded order
$ fq -d mp3 '.headers[0][]' /test.mp3
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |
0x0|49 44 33 |ID3 |.headers[0].magic: "ID3" (Correct)
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |
0x0| 04 | . |.headers[0].version: 4
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |
0x0| 00 | . |.headers[0].revision: 0
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |.headers[0].flags: {}
0x0| 00 | . | unsynchronisation: false
0x0| 00 | . | extended_header: false
0x0| 00 | . | experimental_indicator: false
0x0| 00 | . | unused: 0
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |
0x0| 00 00 00 23 | ...# |.headers[0].size: 35
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |.headers[0].frames: [1]
0x00| 54 53 53 45 00 00| TSSE..| [0]: {}
0x10|00 0f 00 00 03 4c 61 76 66 35 38 2e 34 35 2e 31|.....Lavf58.45.1|
0x20|30 30 00 |00. |
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |
0x20| 00 00 00 00 00 00 00 00 00 00 | .......... |.headers[0].padding: Correct (none) (zero padding)