Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Da flac ad mp3
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Risorse italiane (documentazione e tools)
View previous topic :: View next topic  
Author Message
canduc17
l33t
l33t


Joined: 11 Oct 2005
Posts: 795
Location: Ferrara, Italy

PostPosted: Wed Apr 28, 2010 9:13 pm    Post subject: Da flac ad mp3 Reply with quote

Ecco uno scrippettino interessante per convertire tracce dal formato flac al formato mp3, preservando i metatag.
Vi servono i programmi lame ed id3v2 e vi ritroverete gli mp3 nella cartella "mp3", appunto.
Buon divertimento!
Code:
#!/bin/bash                                                                                                                                                 
# from http://www.linuxtutorialblog.com/post/solution-converting-flac-to-mp3                                                                                 

OUT_DIR="./mp3"
[ ! -d ${OUT_DIR} ] && mkdir -p ${OUT_DIR}

# modify the lame options to your
# preference                     
lame_opts=" --vbr-new -V 2 -B 256 "

for x in *.flac ; do
  FLAC=${x}         
  MP3=`basename "${FLAC%.flac}.mp3"`

  [ -r "$FLAC" ] || { echo can not read file \"$FLAC\" >&1 ; exit 1 ; } ;

  TITLE=""
  TRACKNUMBER=""
  GENRE=""
  DATE=""
  COMMENT=""
  ARTIST=""
  ALBUM=""
  Title=""
  Tracknumber=""
  Genre=""
  Date=""
  Comment=""
  Artist=""
  Album=""

  metaflac --export-tags-to=- "$FLAC" | sed 's/=\(.*\)/="\1"/' > tmp.tmp

  . ./tmp.tmp
  rm tmp.tmp

  [ -z "$TITLE" ] && TITLE="$Title"
  [ -z "$TRACKNUMBER" ] && TRACKNUMBER="$Tracknumber"
  [ -z "$GENRE" ] && GENRE="$Genre"
  [ -z "$DATE" ] && DATE="$Date"
  [ -z "$COMMENT" ] && COMMENT="$Comment"
  [ -z "$ARTIST" ] && ARTIST="$Artist"
  [ -z "$ALBUM" ] && ALBUM="$Album"

  echo "Converting ${FLAC} to MP3 format"

  flac -c -d "$FLAC" | lame ${lame_opts} - ${OUT_DIR}/"$MP3"

  id3v2 \
  -a "$ARTIST" \
  -A "$ALBUM" \
  -t "$TITLE" \
  -c "$COMMENT" \
  -g "$GENRE" \
  -y "$DATE" \
  -T "$TRACKNUMBER" \
  ${OUT_DIR}/"$MP3"

done

_________________
A cow enters a supermarket, does an handstand and dies. (Public toilet graffito)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Risorse italiane (documentazione e tools) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum