2015-09-07 72 views
3

我需要從OGG文件中提取封面。從OGG文件中提取封面圖片

我嘗試解碼存儲在METADATA_BLOCK_PICTURE標籤的base64字符串,至極我用下面的命令得到:

vorbiscomment -R -e 1.ogg 

Base64編碼解碼工作沒有錯誤,但生成的二進制文件是不開放既不像JPG ,也不像PNG。

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

回答

1

有一個在JFIF或PNG流開始之前二進制數據header

我能夠提取從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