IPB

Welcome Guest ( Log In | Register )

How to extract cover album art from mpc?, on Linux terminal
klonuo
post Feb 26 2012, 10:30
Post #1





Group: Members
Posts: 258
Joined: 29-April 10
Member No.: 80274



If using foobar, data is added at the end of the file enclosed in APE tag.

How to extract this from terminal? mpcdec doesn't have much options
Go to the top of the page
+Quote Post
 
Start new topic
Replies
klonuo
post Feb 26 2012, 14:40
Post #2





Group: Members
Posts: 258
Joined: 29-April 10
Member No.: 80274



Sorry for this, but if some mod can delete little script in post #3 it would be great. Thanks

I did lazy googling instead doing it myself, and that snippet is not accurate as it's just correct for my test sample. Problem is that byte offset (read by awk) is address of first byte in default 16 octet line where match is found
I corrected that, added 64 octets (max 256) to avoid more possible wrapping search signatures, and made search for closing APETAGEX offset from start signature position:

CODE
#!/bin/bash

start_pos=`xxd -g0 -c64 "$1" | grep -m1 ffd8ffe0`
offset=`echo $start_pos | cut -d: -f1`
correction=`echo $start_pos | cut -d' ' -f2 | sed 's/ffd8ffe0.*//'`
start_pos=$((0x$offset+${#correction}/2))

if [ $start_pos -gt 0 ]; then
    end_pos=`xxd -g0 -c64 -s 0x$(printf '%x\n' $start_pos) "$1" | grep -m1 4150455441474558d0`
    offset=`echo $end_pos | cut -d: -f1`
    correction=`echo $end_pos | cut -d' ' -f2 | sed 's/4150455441474558d0.*//'`
    end_pos=$((0x$offset+${#correction}/2))
    if [ $end_pos -gt $start_pos ] && [ 1000000 -gt $(($end_pos-$start_pos)) ]; then
        dd ibs=1 count=$(($end_pos-$start_pos)) skip=$start_pos if="$1" of="${1%.*}.jpg"
    fi
else
    echo 'No JPG cover found in APE tag'
fi


Sorry again for this gibberish, I didn't planed to do this

Cheers

This post has been edited by klonuo: Feb 26 2012, 14:41
Go to the top of the page
+Quote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 21st April 2014 - 04:39