mirror of
https://github.com/wader/fq.git
synced 2024-12-26 15:02:28 +03:00
cf15661e9c
Some mpeg versions use LSF (low sampling frequency) when encoding low sample rates which changes a bit how the side info is layed out. Also skip trying to separate data and other_data as after reading up a bit on how main data begin and bit reservoir works i think it was done incorrectly. To know the real audio data length i think you need to decode the huffman tables. Instead just have a "audio_data" field which are the bits with audo data for current and possibly following frames.
107 lines
2.3 KiB
Plaintext
107 lines
2.3 KiB
Plaintext
$ fq -ni
|
|
null> abc | slurp
|
|
error: expr: slurp requires one string argument. ex: ... | slurp("name")
|
|
null> slurp | 1
|
|
error: slurp must be last in pipeline. ex: ... | slurp("name")
|
|
null> abc | slurp("a")
|
|
error: expr: function not defined: abc/0
|
|
null> "a"+1 | slurp("a")
|
|
error: cannot add: string ("a") and number (1)
|
|
null> 123 | slurp("a")
|
|
null> 123, "bb" | slurp("bb")
|
|
null> 123, 456, error("err"), "bb" | slurp("err")
|
|
error: err
|
|
null> spew
|
|
{
|
|
"a": [
|
|
123
|
|
],
|
|
"bb": [
|
|
123,
|
|
"bb"
|
|
],
|
|
"err": [
|
|
123,
|
|
456
|
|
]
|
|
}
|
|
null> spew("bb")
|
|
123
|
|
"bb"
|
|
null> $a
|
|
[
|
|
123
|
|
]
|
|
null> "aa" | slurp("a")
|
|
null> spew
|
|
{
|
|
"a": [
|
|
"aa"
|
|
],
|
|
"bb": [
|
|
123,
|
|
"bb"
|
|
],
|
|
"err": [
|
|
123,
|
|
456
|
|
]
|
|
}
|
|
null> $a
|
|
[
|
|
"aa"
|
|
]
|
|
null> . | repl
|
|
> null> $bb
|
|
[
|
|
123,
|
|
"bb"
|
|
]
|
|
> null> ^D
|
|
null> 123 | slurp("a b")
|
|
error: expr: invalid slurp name "a b", must be a valid identifier. ex: ... | slurp("name")
|
|
null> 123 | slurp(null)
|
|
error: expr: invalid slurp name "null", must be a valid identifier. ex: ... | slurp("name")
|
|
null> ^D
|
|
$ fq -i
|
|
null> 1,2,3 | repl
|
|
> number, ...[0:3][]> ., .*2 | slurp("b")
|
|
> number, ...[0:3][]> if . == 2 then error("err") end | slurp("c")
|
|
error: err
|
|
> number, ...[0:3][]> ^D
|
|
null> spew
|
|
{
|
|
"b": [
|
|
1,
|
|
2,
|
|
2,
|
|
4,
|
|
3,
|
|
6
|
|
],
|
|
"c": [
|
|
1,
|
|
3
|
|
]
|
|
}
|
|
null> ^D
|
|
$ fq -d mp3 -i . test.mp3
|
|
mp3> .frames[0] | slurp("f")
|
|
mp3> $f[]
|
|
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.frames[0]{}: frame (mp3_frame)
|
|
0x20| ff fb 40| ..@| header{}:
|
|
0x30|c0 |. |
|
|
0x30| 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00| ...............| side_info{}:
|
|
0x40|00 00 |.. |
|
|
0x40|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef| xing{}: (xing)
|
|
0x50|02 57 00 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6|.W..............|
|
|
* |until 0xdd.7 (156) | |
|
|
0xd0| 00 00| ..| audio_data: raw bits
|
|
0xe0|00 00 00 |... |
|
|
| | | crc_calculated: "827a" (raw bits)
|
|
mp3> ^D
|
|
$ fq -n slurp
|
|
exitcode: 3
|
|
stderr:
|
|
error: arg: slurp can only be used from interactive repl
|