1
1
mirror of https://github.com/wader/fq.git synced 2024-12-03 13:46:37 +03:00
fq/format/mp3/testdata/header-zeros-frames.fqtest
Mattias Wadman cf15661e9c mp3_frame: Add LSF support and fix incorrect main data handling
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.
2022-08-17 21:36:39 +02:00

99 lines
11 KiB
Plaintext

# ffmpeg -f lavfi -i sine -t 10ms -f mp3 pipe:1 | fq - '.headers._bytes, ("\x00\x00\x00" | tobytes), .frames[0]._bytes' > header-zeros-frames.mp3
$ fq -d mp3 dv header-zeros-frames.mp3
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: header-zeros-frames.mp3 (mp3) 0x0-0xff.7 (256)
| | | headers[0:1]: 0x0-0x2c.7 (45)
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef| [0]{}: header (id3v2) 0x0-0x2c.7 (45)
0x000|49 44 33 |ID3 | magic: "ID3" (valid) 0x0-0x2.7 (3)
0x000| 04 | . | version: 4 0x3-0x3.7 (1)
0x000| 00 | . | revision: 0 0x4-0x4.7 (1)
| | | flags{}: 0x5-0x5.7 (1)
0x000| 00 | . | unsynchronisation: false 0x5-0x5 (0.1)
0x000| 00 | . | extended_header: false 0x5.1-0x5.1 (0.1)
0x000| 00 | . | experimental_indicator: false 0x5.2-0x5.2 (0.1)
0x000| 00 | . | unused: 0 0x5.3-0x5.7 (0.5)
0x000| 00 00 00 23 | ...# | size: 35 0x6-0x9.7 (4)
| | | frames[0:1]: 0xa-0x22.7 (25)
| | | [0]{}: frame 0xa-0x22.7 (25)
0x000| 54 53 53 45 | TSSE | id: "TSSE" (Software/Hardware and settings used for encoding) 0xa-0xd.7 (4)
0x000| 00 00| ..| size: 15 0xe-0x11.7 (4)
0x010|00 0f |.. |
| | | flags{}: 0x12-0x13.7 (2)
0x010| 00 | . | unused0: 0 0x12-0x12 (0.1)
0x010| 00 | . | tag_alter_preservation: false 0x12.1-0x12.1 (0.1)
0x010| 00 | . | file_alter_preservation: false 0x12.2-0x12.2 (0.1)
0x010| 00 | . | read_only: false 0x12.3-0x12.3 (0.1)
0x010| 00 00 | .. | unused1: 0 0x12.4-0x13 (0.5)
0x010| 00 | . | grouping_identity: false 0x13.1-0x13.1 (0.1)
0x010| 00 | . | unused2: 0 0x13.2-0x13.3 (0.2)
0x010| 00 | . | compression: false 0x13.4-0x13.4 (0.1)
0x010| 00 | . | encryption: false 0x13.5-0x13.5 (0.1)
0x010| 00 | . | unsync: false 0x13.6-0x13.6 (0.1)
0x010| 00 | . | data_length_indicator: false 0x13.7-0x13.7 (0.1)
0x010| 03 | . | text_encoding: "utf8" (3) 0x14-0x14.7 (1)
0x010| 4c 61 76 66 35 38 2e 34 35 2e 31| Lavf58.45.1| text: "Lavf58.45.100" 0x15-0x22.7 (14)
0x020|30 30 00 |00. |
0x020| 00 00 00 00 00 00 00 00 00 00 | .......... | padding: raw bits (all zero) 0x23-0x2c.7 (10)
0x020| 00 00 00| ...| unknown0: raw bits 0x2d-0x2f.7 (3)
| | | frames[0:1]: 0x30-0xff.7 (208)
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef| [0]{}: frame (mp3_frame) 0x30-0xff.7 (208)
| | | header{}: 0x30-0x33.7 (4)
0x030|ff fb |.. | sync: 0b11111111111 (valid) 0x30-0x31.2 (1.3)
0x030| fb | . | mpeg_version: "1" (3) (MPEG Version 1) 0x31.3-0x31.4 (0.2)
0x030| fb | . | layer: 3 (1) (MPEG Layer 3) 0x31.5-0x31.6 (0.2)
| | | sample_count: 1152 0x31.7-NA (0)
0x030| fb | . | protection_absent: true (No CRC) 0x31.7-0x31.7 (0.1)
0x030| 50 | P | bitrate: 64000 (5) 0x32-0x32.3 (0.4)
0x030| 50 | P | sample_rate: 44100 (0) 0x32.4-0x32.5 (0.2)
0x030| 50 | P | padding: "not_padded" (0b0) 0x32.6-0x32.6 (0.1)
0x030| 50 | P | private: 0 0x32.7-0x32.7 (0.1)
0x030| c4 | . | channels: "mono" (0b11) 0x33-0x33.1 (0.2)
0x030| c4 | . | channel_mode: "none" (0b0) 0x33.2-0x33.3 (0.2)
0x030| c4 | . | copyright: 0 0x33.4-0x33.4 (0.1)
0x030| c4 | . | original: 1 0x33.5-0x33.5 (0.1)
0x030| c4 | . | emphasis: "none" (0b0) 0x33.6-0x33.7 (0.2)
| | | side_info{}: 0x34-0x44.7 (17)
0x030| 00 00 | .. | main_data_begin: 0 0x34-0x35 (1.1)
0x030| 00 | . | share: 0 0x35.1-0x35.5 (0.5)
0x030| 00 0a | .. | scfsi0: 0 0x35.6-0x36.1 (0.4)
| | | granules[0:2]: 0x36.2-0x44.7 (14.6)
| | | [0][0:1]: granule 0x36.2-0x3d.4 (7.3)
| | | [0]{}: channel 0x36.2-0x3d.4 (7.3)
0x030| 0a 2c | ., | part2_3_length: 651 0x36.2-0x37.5 (1.4)
0x030| 2c 43 | ,C | big_values: 33 0x37.6-0x38.6 (1.1)
0x030| 43 2e | C. | global_gain: 151 0x38.7-0x39.6 (1)
0x030| 2e 55 | .U | scalefac_compress: 2 0x39.7-0x3a.2 (0.4)
0x030| 55 | U | blocksplit_flag: 1 0x3a.3-0x3a.3 (0.1)
0x030| 55 | U | block_type: "start block" (1) 0x3a.4-0x3a.5 (0.2)
0x030| 55 | U | switch_point: 0 0x3a.6-0x3a.6 (0.1)
0x030| 55 94 | U. | table_select0: 25 0x3a.7-0x3b.3 (0.5)
0x030| 94 80 | .. | table_select1: 9 0x3b.4-0x3c (0.5)
0x030| 80 | . | subblock_gain0: 0 0x3c.1-0x3c.3 (0.3)
0x030| 80 | . | subblock_gain1: 0 0x3c.4-0x3c.6 (0.3)
0x030| 80 01 | .. | subblock_gain2: 0 0x3c.7-0x3d.1 (0.3)
0x030| 01 | . | preflag: 0 0x3d.2-0x3d.2 (0.1)
0x030| 01 | . | scalefac_scale: 0 0x3d.3-0x3d.3 (0.1)
0x030| 01 | . | count1table_select: 0 0x3d.4-0x3d.4 (0.1)
| | | [1][0:1]: granule 0x3d.5-0x44.7 (7.3)
| | | [0]{}: channel 0x3d.5-0x44.7 (7.3)
0x030| 01 80 93| ...| part2_3_length: 769 0x3d.5-0x3f (1.4)
0x030| 93| .| big_values: 77 0x3f.1-0x40.1 (1.1)
0x040|6b |k |
0x040|6b 27 |k' | global_gain: 172 0x40.2-0x41.1 (1)
0x040| 27 | ' | scalefac_compress: 9 0x41.2-0x41.5 (0.4)
0x040| 27 | ' | blocksplit_flag: 1 0x41.6-0x41.6 (0.1)
0x040| 27 30 | '0 | block_type: "3 short windows" (2) 0x41.7-0x42 (0.2)
0x040| 30 | 0 | switch_point: 0 0x42.1-0x42.1 (0.1)
0x040| 30 | 0 | table_select0: 24 0x42.2-0x42.6 (0.5)
0x040| 30 80 | 0. | table_select1: 8 0x42.7-0x43.3 (0.5)
0x040| 80 | . | subblock_gain0: 0 0x43.4-0x43.6 (0.3)
0x040| 80 00 | .. | subblock_gain1: 0 0x43.7-0x44.1 (0.3)
0x040| 00 | . | subblock_gain2: 0 0x44.2-0x44.4 (0.3)
0x040| 00 | . | preflag: 0 0x44.5-0x44.5 (0.1)
0x040| 00 | . | scalefac_scale: 0 0x44.6-0x44.6 (0.1)
0x040| 00 | . | count1table_select: 0 0x44.7-0x44.7 (0.1)
0x040| 07 aa c3 8e 33 85 d3 64 f1 a1 c1| ....3..d...| audio_data: raw bits 0x45-0xff.7 (187)
0x050|08 1c 58 1f 5e 1f 18 1c 46 04 1e 89 e5 b3 2e 5a|..X.^...F......Z|
* |until 0xff.7 (end) (187) | |
| | | crc_calculated: "e5b0" (raw bits) 0x100-NA (0)
| | | footers[0:0]: 0x100-NA (0)