From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on sa.int.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,SPF_PASS autolearn=ham version=3.2.5 Message-ID: <48E7BE3C.6050307@rambler.ru> Date: Sat, 04 Oct 2008 23:04:28 +0400 From: "Kharitonov A. Dmitry" User-Agent: Thunderbird 2.0.0.14 (X11/20080719) MIME-Version: 1.0 To: ALT Linux Community general discussions References: <91dc8dbf0810040957i32d0fca3id3adbddb53f615bb@mail.gmail.com> <20081004170049.GN5917@wrars-comp.wrarsdomain> <91dc8dbf0810041055qfabd198hcc794209978a305@mail.gmail.com> In-Reply-To: <91dc8dbf0810041055qfabd198hcc794209978a305@mail.gmail.com> Content-Type: multipart/mixed; boundary="------------000509010809020609010602" Subject: Re: [Comm] =?koi8-r?b?68HLINDPzsnaydTYIMLJ1NLFytQgbXAzPw==?= X-BeenThere: community@lists.altlinux.org X-Mailman-Version: 2.1.10b3 Precedence: list Reply-To: ALT Linux Community general discussions List-Id: ALT Linux Community general discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Oct 2008 19:04:24 -0000 Archived-At: List-Archive: List-Post: This is a multi-part message in MIME format. --------------000509010809020609010602 Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 8bit > С понижением битрейта разобрался, достаточно просто lame... С ходу > подумал, глядя на примеры, что он енкодит только wav и raw, оказалось, > и mp3 тоже. > > Теперь теги > По поводу тегов, думаю, услышу волшебное слово mp3info > > > Ну с тегами всё совсем не просто... Гляньте скрипт --------------000509010809020609010602 Content-Type: text/plain; name="encoder.sh" Content-Transfer-Encoding: 8bit Content-Disposition: inline; filename="encoder.sh" #!/bin/bash # Проверка наличия необходимых программ ex=0; if ! which madplay &> /dev/null; then echo "${0##*/}: madplay is not found"; ex=1; fi if ! which id3v2 &> /dev/null; then echo "${0##*/}: id3v2 is not found"; ex=1; fi if ! which normalize &> /dev/null; then echo "${0##*/}: normalize is not found"; ex=1; fi if ! which mp3info &> /dev/null; then echo "${0##*/}: mp3info is not found"; ex=1; fi if ! which lame &> /dev/null; then echo "${0##*/}: lame is not found"; ex=1; fi if ((ex)); then exit 1; fi # Получение количества процессоров для организации параллейных вычислений NPROCS=`egrep -cs ^cpu[0-9]+ /proc/stat` [ "$NPROCS" -gt 1 ] 2>/dev/null || NPROCS=1 ((NPROCS=NPROCS*2)) n=1 PROCFILE="/tmp/${0##*/}-$n.proc" while [ -f "$PROCFILE" ]; do ((n++)); PROCFILE="/tmp/${0##*/}-$n.proc"; done r=$(echo -ne "\r") OUTPUT= INPUT= MAXBITRATE=128 AVRBITRATE=112 RESAMPLE= CRESAMPLE= BOOK= TAG3= VALID_BITRATE=( 32 40 48 56 64 80 96 112 128 160 192 224 256 320 ) if (($#>=1)); then for opt in "$@"; do case "$opt" in --book=*) MAXBITRATE="$(echo "$opt" | cut -d '=' -f 2)" i=1; while ((${VALID_BITRATE[i]}"$OUTFILE.mp3" id3v2 -l "$file" | sed -e "s/$r//g" | { while read sfield; do case ${sfield:0:4} in id3v | AENC | APIC | COMM | COMR | ENCR | EQUA | ETCO | \ GEOB | GRID | IPLS | LINK | MCDI | MLLT | OWNE | PRIV | \ PCNT | POPM | POSS | RBUF | RVAD | RVRB | SYLT | SYTC | \ TALB | TBPM | TCOM | TCON | TCOP | TDAT | TDLY | TENC | \ TEXT | TFLT | TIME | TIT1 | TIT2 | TIT3 | TKEY | TLAN | \ TLEN | TMED | TOAL | TOFN | TOLY | TOPE | TORY | TOWN | \ TPE1 | TPE2 | TPE3 | TPE4 | TPOS | TPUB | TRCK | TRDA | \ TRSN | TRSO | TSIZ | TSRC | TSSE | TXXX | TYER | UFID | \ USER | USLT | WCOM | WCOP | WOAF | WOAR | WOAS | WORS | \ WPAY | WPUB | WXXX) echo -ne "\\n$sfield">>"$OUTFILE.mp3" ;; *) echo -n "\\\\r\\\\n$sfield">>"$OUTFILE.mp3" ;; esac done } TAG3="$(cat "$OUTFILE.mp3")" # id3v2 -l "$TEMPFILE"; # cat "$OUTPUT/tmp.id3" if echo "$TAG3" | grep "id3v1 tag info for"> /dev/null; then Track=$(mp3info -p "%n" "$INPUT/$file") Artist=$(mp3info -p "%a" "$INPUT/$file") Comment=$(mp3info -p "%c" "$INPUT/$file") Genre=$(mp3info -p "%G" "$INPUT/$file") Album=$(mp3info -p "%l" "$INPUT/$file") Title=$(mp3info -p "%t" "$INPUT/$file") Year=$(mp3info -p "%y" "$INPUT/$file") fi # Ожидание освобождения слота процессора NSLOT= while [ -z "$NSLOT" ]; do NSLOT=$(cat "$PROCFILE" | { while read proc; do if [ "${proc:0:4}" == "SLOT" ]; then proc=${proc:4}; ((NSLOT=${proc%%=*}+0)) ((proc=${proc##*=}+0)) if ((NSLOT>0)) & ((NSLOT<=NPROCS)) & ( ! ps -p "$proc"> /dev/null 2>&1 ); then echo $NSLOT; break; fi fi done [ -z "$NSLOT" ] && echo 0 }) sleep 2 done ((NSLOT<1)) && NSLOT=1 echo "$(date) SLOT#$NSLOT=$file" { madplay -o "wave:$OUTFILE.wav" "$INPUT/$file" > /dev/null 2>&1 # && echo -e "\nDecoding DONE" normalize --peak "$OUTFILE.wav" > /dev/null 2>&1 lame $CRESAMPLE --abr $AVRBITRATE -B $MAXBITRATE -q 0 "$OUTFILE.wav" "$OUTFILE.mp3" > /dev/null 2>&1 if echo "$TAG3" | grep "id3v1 tag info for"> /dev/null; then mp3info -a "$Artist" "$OUTFILE.mp3" > /dev/null 2>&1 mp3info -c "$Comment" "$OUTFILE.mp3" > /dev/null 2>&1 mp3info -g "$Genre" "$OUTFILE.mp3" > /dev/null 2>&1 mp3info -l "$Album" "$OUTFILE.mp3" > /dev/null 2>&1 mp3info -n "$Track" "$OUTFILE.mp3" > /dev/null 2>&1 mp3info -y "$Year" "$OUTFILE.mp3" > /dev/null 2>&1 mp3info -t "$Title" "$OUTFILE.mp3" > /dev/null 2>&1 fi id3v2=1 echo "$TAG3" | { while read sfield; do if (( id3v2 )); then if echo "$TAG3" | grep "id3v2 tag info for"> /dev/null; then id3v2=0; fi continue fi fieldname=${sfield:0:4} case $fieldname in TCON) fieldcont=" "$(echo "$sfield" | cut -d ':' -f 2- | cut -d '(' -f 2 | cut -d ')' -f 1) ;; WXXX | COMM) fieldcont=$(echo "$sfield" | cut -d ':' -f 3-) ;; *) fieldcont=$(echo "$sfield" | cut -d ':' -f 2-) ;; esac while [ "${fieldcont:0:1}" == " " ]; do fieldcont=${fieldcont:1}; done [ -n "$fieldcont" ] && id3v2 --id3v2-only "--$fieldname" "$(echo -e "$fieldcont")" "$OUTFILE.mp3" > /dev/null 2>&1 done } rm -f "$OUTFILE.wav" > /dev/null 2>&1 echo "$(date) Stop#$NSLOT=$file" } & proc=$! :>"$PROCFILE.proc" for ((SLOT=1; SLOT<=NPROCS; SLOT++)); do SLOTproc=$(cat "$PROCFILE" | { while read proc; do if [ "${proc:0:4}" == "SLOT" ]; then proc=${proc:4}; ((NSLOT=${proc%%=*}+0)) ((proc=${proc##*=}+0)) if ((NSLOT==SLOT)); then echo $proc; break; fi fi done }) (( SLOTproc=SLOTproc+0 )) if ((NSLOT==SLOT)); then echo "SLOT$SLOT=$proc" >> "$PROCFILE.proc" else echo "SLOT$SLOT=$SLOTproc" >> "$PROCFILE.proc" fi done mv "$PROCFILE.proc" "$PROCFILE" ;; *) cp -v "$INPUT/$file" "$OUTPUT/$diroutput/$file" ;; esac fi done } if ! echo "$@" | grep -e "--proc="> /dev/null 2>&1; then # Ожидание освобождения процессора echo "Ending..." SLOTWAIT=1 while [ -n "$SLOTWAIT" ]; do SLOTWAIT=$(cat "$PROCFILE" | { while read proc; do if [ "${proc:0:4}" == "SLOT" ]; then proc=${proc:4}; ((SLOT[${proc%%=*}]=${proc##*=}+0)) fi done for ((NSLOT=1; NSLOT<=NPROCS; NSLOT++)); do # echo "SLOT[$NSLOT]=${SLOT[NSLOT]}" if ((${SLOT[NSLOT]})) && ps -p "${SLOT[NSLOT]}"> /dev/null 2>&1; then echo -n 1; fi done }) [ -n "$SLOTWAIT" ] && sleep 2 done rm -f "$PROCFILE" fi echo "Process fineshed at "`date` --------------000509010809020609010602--