4

我需要从 OGG 文件中提取封面。

我正在尝试解码存储在 METADATA_BLOCK_PICTURE 标记中的 base64 字符串,我通过以下命令得到:

vorbiscomment -R -e 1.ogg

Base64 解码工作正常,但生成的二进制文件既不像 JPG 也不像 PNG 那样打开。

示例文件:http ://regress78.com/1.ogg

4

1 回答 1

2

在 JFIF 或 PNG 流开始之前,二进制数据上有一个标头。

从 hexdump 解析出标头长度(在本例中为 42 个字节)后,我能够提取有效的 jpeg 文件:

$ vorbiscomment -R -e 1.ogg | grep METADATA_BLOCK_PICTURE | cut -d '=' -f 2 | base64 -d > 1.dat
base64: invalid input
$ dd if=1.dat of=1.jpeg bs=1 skip=42
114424+0 records in
114424+0 records out
114424 bytes (114 kB) copied, 0.112082 s, 1.0 MB/s
$ file 1.jpeg
1.jpeg: JPEG image data, JFIF standard 1.01, resolution (DPI), density 72x72, segment length 16, Exif Standard: [TIFF image data, big-endian, direntries=1], baseline, precision 8, 496x500, frames 3
于 2015-09-30T23:57:52.350 回答