File indexing completed on 2025-01-05 04:26:20
0001 /**************************************************************************************** 0002 * Copyright (c) 2010 Téo Mrnjavac <teo@kde.org> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #include "TranscodingMp3Format.h" 0018 0019 #include <KLocalizedString> 0020 0021 using namespace Transcoding; 0022 0023 Mp3Format::Mp3Format() 0024 { 0025 m_encoder = MP3; 0026 m_fileExtension = QStringLiteral("mp3"); 0027 const QString description1 = 0028 i18n( "The bitrate is a measure of the quantity of data used to represent a " 0029 "second of the audio track.<br>The <b>MP3</b> encoder used by Amarok supports " 0030 "a <a href=http://en.wikipedia.org/wiki/MP3#VBR>variable bitrate (VBR)</a> " 0031 "setting, which means that the bitrate value fluctuates along the track " 0032 "based on the complexity of the audio content. More complex intervals of " 0033 "data are encoded with a higher bitrate than less complex ones; this " 0034 "approach yields overall better quality and a smaller file than having a " 0035 "constant bitrate throughout the track.<br>" 0036 "For this reason, the bitrate measure in this slider is just an estimate " 0037 "of the average bitrate of the encoded track.<br>" 0038 "<b>160kb/s</b> is a good choice for music listening on a portable player.<br/>" 0039 "Anything below <b>120kb/s</b> might be unsatisfactory for music and anything above " 0040 "<b>205kb/s</b> is probably overkill."); 0041 QStringList valueLabels; 0042 QByteArray vbr = "VBR ~%1kb/s"; 0043 valueLabels 0044 << i18n( vbr, 80 ) 0045 << i18n( vbr, 100 ) 0046 << i18n( vbr, 120 ) 0047 << i18n( vbr, 140 ) 0048 << i18n( vbr, 160 ) 0049 << i18n( vbr, 175 ) 0050 << i18n( vbr, 190 ) 0051 << i18n( vbr, 205 ) 0052 << i18n( vbr, 220 ) 0053 << i18n( vbr, 240 ); 0054 0055 m_propertyList << Property::Tradeoff( "quality", i18n( "Expected average bitrate for variable bitrate encoding" ), description1, 0056 i18n( "Smaller file" ), i18n( "Better sound quality" ), 0057 valueLabels, 5 ); 0058 } 0059 0060 QString 0061 Mp3Format::prettyName() const 0062 { 0063 return i18n( "MP3" ); 0064 } 0065 0066 QString 0067 Mp3Format::description() const 0068 { 0069 return i18nc( "Feel free to redirect the english Wikipedia link to a local version, if " 0070 "it exists.", 0071 "<a href=http://en.wikipedia.org/wiki/MP3>MPEG Audio Layer 3</a> (MP3) is " 0072 "a patented digital audio codec using a form of lossy data compression." 0073 "<br>In spite of its shortcomings, it is a common format for consumer " 0074 "audio storage, and is widely supported on portable music players." ); 0075 } 0076 0077 QIcon 0078 Mp3Format::icon() const 0079 { 0080 return QIcon::fromTheme( QStringLiteral("audio-x-generic") ); //TODO: get a *real* icon! 0081 } 0082 0083 QStringList 0084 Mp3Format::ffmpegParameters( const Configuration &configuration ) const 0085 { 0086 QStringList parameters; 0087 parameters << QStringLiteral("-acodec") << QStringLiteral("libmp3lame"); 0088 foreach( const Property &property, m_propertyList ) 0089 { 0090 if( !configuration.property( property.name() ).isNull() 0091 && configuration.property( property.name() ).type() == property.variantType() ) 0092 { 0093 if( property.name() == "quality" ) 0094 { 0095 int ffmpegQuality = qAbs( configuration.property( "quality" ).toInt() - 9 ); 0096 parameters << QStringLiteral("-aq") << QString::number( ffmpegQuality ); 0097 } 0098 } 0099 } 0100 parameters << QStringLiteral("-vcodec") << QStringLiteral("copy"); // keep album art unchanged 0101 return parameters; 0102 } 0103 0104 bool 0105 Mp3Format::verifyAvailability( const QString &ffmpegOutput ) const 0106 { 0107 return ffmpegOutput.contains( QRegExp( QStringLiteral("^ .EA... mp3 +.*libmp3lame") ) ); 0108 }