Jump to content

Amarok/Archives/Convert current track to MPEG4

From KDE Community Wiki
Revision as of 11:00, 14 December 2012 by Neverendingo (talk | contribs) (Text replace - "\[\[Category:.*\]\]" to "")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

As an user of the cell phone SonyEricsson K750i, I really like listening to music while I can't use Amarok. To save a few megabytes on my memory stick, I created a shell script which converts the current song automatically to MPEG4-AAC.

Prerequisites

You need the MP3-encoder lame to convert your MP3s to wave files, the [faac encoder with MPEG4 support and, of course, Amarok.

Was true. Now you need only ffmpeg [1].

The script

Save this file as convertcurrent.sh and chmod +x it.

#!/bin/bash
file=`dcop amarok player path`
filename=${file##*/}
dirname=${file%/*}

if [ -f "$file" ]; then cp "$file" /tmp
fi

INPUT="/tmp/$filename"

if [ -f $INPUT ]; then
        chmod +w $INPUT
        OUTPUT="/tmp/${filename%.*}.m4a"
        ffmpeg -i "/tmp/$filename" $OUTPUT
        mv $OUTPUT $dirname/
        exit 0
fi

Limitations

  • due to a bug in faac, quality under 100 is not possible (faac crashes sometimes then); this valid for previous version -- the current one doesn't use faac, but ffmpeg and it does not set any parameters.
  • meta tags aren't included in the converted file; again -- valid for previous version, now they are included, because conversion is direct.

Usage

Just type in "./convertcurrent.sh". Then your currently playing file will be converted and put into the same directory as the original file, but with the extension .m4a.