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

mp3,README: some cleanup

This commit is contained in:
Mattias Wadman 2021-09-04 11:39:33 +02:00
parent 905c0ab74e
commit c4a31205c0
2 changed files with 9 additions and 3 deletions

View File

@ -37,7 +37,7 @@ $ fq '.headers[].frames[] | select(.id == "APIC").picture.chunks[] | select(.typ
}
 
<b># Extract PNG file</b> 
$ fq '.headers[].frames[] | select(.id == "APIC")?.picture._bits' file.mp3 > file.png 
$ fq '.headers[].frames[] | select(.id == "APIC")?.picture | tobits' file.mp3 > file.png 
$ file file.png 
file.png: PNG image data, 320 x 240, 8-bit/color RGB, non-interlaced
 

View File

@ -23,7 +23,11 @@ func init() {
DecodeFn: mp3Decode,
Dependencies: []decode.Dependency{
{Names: []string{format.ID3V2}, Formats: &headerFormat},
{Names: []string{format.ID3V1, format.ID3V11, format.APEV2}, Formats: &footerFormat},
{Names: []string{
format.ID3V1,
format.ID3V11,
format.APEV2,
}, Formats: &footerFormat},
{Names: []string{format.MP3_FRAME}, Formats: &mp3Frame},
},
})
@ -44,7 +48,9 @@ func mp3Decode(d *decode.D, in interface{}) interface{} {
d.FieldArrayFn("frames", func(d *decode.D) {
for d.NotEnd() {
startFindSync := d.Pos()
syncLen, _, err := d.TryPeekFind(16, 8, func(v uint64) bool { return v&0b1111_1111_1110_0000 == 0b1111_1111_1110_0000 }, d.BitsLeft())
syncLen, _, err := d.TryPeekFind(16, 8, func(v uint64) bool {
return v&0b1111_1111_1110_0000 == 0b1111_1111_1110_0000
}, d.BitsLeft())
if err != nil {
break
}