[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Aus Ogg und FLAC eine mp3 Daten-CD erstellen



Hallo Thomas,

On 06/17/2008 11:29 PM, Thomas Kreft wrote:
Kennt jemand eine _bequeme_ Möglichkeit, daraus eine Daten-CD zu erstellen, wobei alle nicht-mp3 Dateien automatisch nach mp3 gewandelt werden?

"bequem" ist ja immer Ansichtssache, ich hatte mal ein Bash-Script geschrieben, was meine gesamte Musiksammlung in ein Format bringt, hab es jetzt schnell für deine Angaben geändert. Es "spiegelt" einen Verzeichnisbaum mit Musikdateien in ein neues Verzeichnis und konvertiert dabei in ein Zielformat. (mp3 wird kopiert, andere Audioformate konvertiert und der Rest wird ignoriert)
Es verwendet mplayer und lame.

Vielleicht nutzt es Dir/jemandem ja was, ich hab es angehängt.

Mit freundlichen Grüßen,
Christian Franke
#!/bin/bash

# Copyright (C) 2008 Christian Franke
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# Usage: ./converter <indir> <outdir>
#
# Bugreports to <cfchris6@yahoo.de>

convert() {
    BITRATE=192 # change target bitrate here
    RELPATH="$(echo "${2}" | sed "s|^${3}||")"
    if [ -d "${2}" ]; then
        mkdir "${4}/${RELPATH}" &> /dev/null
    else
        EXTENSION="$(echo "${2}" | sed 's|^.*\.||' | tr '[A-Z]' '[a-z]')"
        FILENAME="$(echo "${RELPATH}" | sed 's|\.\w\{1,\}$||' )"
        if [ "${EXTENSION}" = "mp3" ]; then
            echo "Copyied ${2}"
            cp "${2}" "${4}/${RELPATH}"
        else if [ "${EXTENSION}" = "ogg" -o "${EXTENSION}" = "wma" -o "${EXTENSION}" = "flac" ]; then 
            echo -n "Dumping ${2} ..."
            mplayer "${2}" -ao pcm &> /dev/null || ( \
                echo "[ Error ]" 1>&2 ; \
                rm -f audiodump.wav &> /dev/null; \
                exit 1 ) || exit 1
            echo "[ Done ]"
            echo -n "Encoding ${2} ..." 
            lame -h -b ${BITRATE} audiodump.wav "${4}/${FILENAME}.mp3" &> /dev/null || ( \
                echo "[ Error ]" 1>&2 ; \
                rm -f audiodump.wav &> /dev/null; \
                rm -f "${4}/${FILENAME}.mp3" &> /dev/null; \
                exit 1 ) || exit 1
            echo "[ Done ]"
            rm -f audiodump.wav &> /dev/null;
        else
            echo "${2} has unsupported format, skipping."
        fi fi
    fi
}

if [ "${1}" = "convert" ] && [ $# -eq 4 ]; then
    convert "$@"
    exit $?
fi

if [ $# -ne 2 ]; then
    echo "Error." 1>&2
    echo "Usage:" 1>&2
    echo "${0} <indir> <outdir>" 1>&2
    exit 1
fi
if [ ! -d "${1}" ]; then
    echo "Error." 1>&2
    echo "<indir> is no directory"
    exit 1
fi

if [ ! -d "${2}" ]; then
    mkdir "${2}" &> /dev/null || ( \
        echo "Error."; \
        echo "<outdir> could not be created."; \
        exit 1 ) || exit 1
    echo "<outdir> created"
fi

find "${1}" -exec ${0} convert "{}" "${1}" "${2}" \;

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: