1
1
mirror of https://github.com/wader/fq.git synced 2024-11-24 03:05:22 +03:00

id3v2: Add WXXX (desc/url) frame support

This commit is contained in:
Mattias Wadman 2023-05-02 11:54:11 +02:00
parent ddd7b0e439
commit d010dcec06
3 changed files with 97 additions and 0 deletions

View File

@ -527,6 +527,7 @@ func decodeFrame(d *decode.D, version int) uint64 {
encoding := d.FieldU8("text_encoding", encodingNames) encoding := d.FieldU8("text_encoding", encodingNames)
d.FieldStrFn("text", textFn(int(encoding), int(d.BitsLeft()/8))) d.FieldStrFn("text", textFn(int(encoding), int(d.BitsLeft()/8)))
}, },
// User defined... "TXX" // User defined... "TXX"
// Frame size $xx xx xx // Frame size $xx xx xx
// Text encoding $xx // Text encoding $xx
@ -543,6 +544,23 @@ func decodeFrame(d *decode.D, version int) uint64 {
d.FieldStrFn("description", textNullLenFn(int(encoding), int(d.BitsLeft()/8))) d.FieldStrFn("description", textNullLenFn(int(encoding), int(d.BitsLeft()/8)))
d.FieldStrFn("value", textFn(int(encoding), int(d.BitsLeft()/8))) d.FieldStrFn("value", textFn(int(encoding), int(d.BitsLeft()/8)))
}, },
// User defined... "WXX"
// Frame size $xx xx xx
// Text encoding $xx
// Description <textstring> $00 (00)
// URL <textstring>
//
// <Header for 'User defined URL link frame', ID: "WXXX">
// Text encoding $xx
// Description <text string according to encoding> $00 (00)
// URL <text string>
"WXXX": func(d *decode.D) {
encoding := d.FieldU8("text_encoding", encodingNames)
d.FieldStrFn("description", textNullLenFn(int(encoding), int(d.BitsLeft()/8)))
d.FieldStrFn("url", textFn(int(encoding), int(d.BitsLeft()/8)))
},
// <Header for 'Private frame', ID: "PRIV"> // <Header for 'Private frame', ID: "PRIV">
// Owner identifier <text string> $00 // Owner identifier <text string> $00
// The private data <binary data> // The private data <binary data>
@ -559,6 +577,8 @@ func decodeFrame(d *decode.D, version int) uint64 {
idNormalized = "COMM" idNormalized = "COMM"
case id == "TXX", id == "TXXX": case id == "TXX", id == "TXXX":
idNormalized = "TXXX" idNormalized = "TXXX"
case id == "WXX", id == "WXXX":
idNormalized = "WXXX"
case len(id) > 0 && id[0] == 'T': case len(id) > 0 && id[0] == 'T':
idNormalized = "T000" idNormalized = "T000"
} }

BIN
format/id3/testdata/txxx-wxxx vendored Normal file

Binary file not shown.

77
format/id3/testdata/txxx-wxxx.fqtest vendored Normal file
View File

@ -0,0 +1,77 @@
# ffmpeg -f lavfi -i sine -t 1ms -write_xing 0 -write_id3v2 0 -write_id3v1 0 -f mp3 test.mp3
# eyeD3 --user-text-frame=txxx-desc:txxx-text --user-url-frame=wxxx-desc:wxxx-url test.mp3
# fq '.headers[0]._bits' test.mp3 > txxx-wxxx
$ fq -d id3v2 dv txxx-wxxx
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: txxx-wxxx (id3v2) 0x0-0x15b.7 (348)
| | | header{}: 0x0-0x9.7 (10)
0x000|49 44 33 |ID3 | magic: "ID3" (valid) 0x0-0x2.7 (3)
0x000| 04 | . | version: 4 (valid) 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 02 52 | ...R | size: 338 0x6-0x9.7 (4)
| | | frames[0:3]: 0xa-0x5b.7 (82)
| | | [0]{}: frame 0xa-0x20.7 (23)
0x000| 54 53 53 45 | TSSE | id: "TSSE" (Software/Hardware and settings used for encoding) 0xa-0xd.7 (4)
0x000| 00 00| ..| size: 13 0xe-0x11.7 (4)
0x010|00 0d |.. |
| | | 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 36 30 2e 33 2e 31 30| Lavf60.3.10| text: "Lavf60.3.100" 0x15-0x20.7 (12)
0x020|30 |0 |
| | | [1]{}: frame 0x21-0x3e.7 (30)
0x020| 54 58 58 58 | TXXX | id: "TXXX" (User defined text information frame) 0x21-0x24.7 (4)
0x020| 00 00 00 14 | .... | size: 20 0x25-0x28.7 (4)
| | | flags{}: 0x29-0x2a.7 (2)
0x020| 00 | . | unused0: 0 0x29-0x29 (0.1)
0x020| 00 | . | tag_alter_preservation: false 0x29.1-0x29.1 (0.1)
0x020| 00 | . | file_alter_preservation: false 0x29.2-0x29.2 (0.1)
0x020| 00 | . | read_only: false 0x29.3-0x29.3 (0.1)
0x020| 00 00 | .. | unused1: 0 0x29.4-0x2a (0.5)
0x020| 00 | . | grouping_identity: false 0x2a.1-0x2a.1 (0.1)
0x020| 00 | . | unused2: 0 0x2a.2-0x2a.3 (0.2)
0x020| 00 | . | compression: false 0x2a.4-0x2a.4 (0.1)
0x020| 00 | . | encryption: false 0x2a.5-0x2a.5 (0.1)
0x020| 00 | . | unsync: false 0x2a.6-0x2a.6 (0.1)
0x020| 00 | . | data_length_indicator: false 0x2a.7-0x2a.7 (0.1)
0x020| 03 | . | text_encoding: "utf8" (3) 0x2b-0x2b.7 (1)
0x020| 74 78 78 78| txxx| description: "txxx-desc" 0x2c-0x35.7 (10)
0x030|2d 64 65 73 63 00 |-desc. |
0x030| 74 78 78 78 2d 74 65 78 74 | txxx-text | value: "txxx-text" 0x36-0x3e.7 (9)
| | | [2]{}: frame 0x3f-0x5b.7 (29)
0x030| 57| W| id: "WXXX" (User defined URL link frame) 0x3f-0x42.7 (4)
0x040|58 58 58 |XXX |
0x040| 00 00 00 13 | .... | size: 19 0x43-0x46.7 (4)
| | | flags{}: 0x47-0x48.7 (2)
0x040| 00 | . | unused0: 0 0x47-0x47 (0.1)
0x040| 00 | . | tag_alter_preservation: false 0x47.1-0x47.1 (0.1)
0x040| 00 | . | file_alter_preservation: false 0x47.2-0x47.2 (0.1)
0x040| 00 | . | read_only: false 0x47.3-0x47.3 (0.1)
0x040| 00 00 | .. | unused1: 0 0x47.4-0x48 (0.5)
0x040| 00 | . | grouping_identity: false 0x48.1-0x48.1 (0.1)
0x040| 00 | . | unused2: 0 0x48.2-0x48.3 (0.2)
0x040| 00 | . | compression: false 0x48.4-0x48.4 (0.1)
0x040| 00 | . | encryption: false 0x48.5-0x48.5 (0.1)
0x040| 00 | . | unsync: false 0x48.6-0x48.6 (0.1)
0x040| 00 | . | data_length_indicator: false 0x48.7-0x48.7 (0.1)
0x040| 00 | . | text_encoding: "iso_8859-1" (0) 0x49-0x49.7 (1)
0x040| 77 78 78 78 2d 64| wxxx-d| description: "wxxx-desc" 0x4a-0x53.7 (10)
0x050|65 73 63 00 |esc. |
0x050| 77 78 78 78 2d 75 72 6c | wxxx-url | url: "wxxx-url" 0x54-0x5b.7 (8)
0x050| 00 00 00 00| ....| padding: raw bits (all zero) 0x5c-0x15b.7 (256)
0x060|00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|................|
* |until 0x15b.7 (end) (256) | |