我尝试使用以下命令将.m4a
文件转换为.mp3
文件:ffmpeg
$ ffmpeg -i music.m4a music.mp3
不幸的是,我得到的输出结果为零字节大小的文件。该命令的输出如下:
FFmpeg version 0.6-4:0.6-2ubuntu6.2, Copyright (c) 2000-2010 the FFmpeg developers
built on Sep 16 2011 17:11:24 with gcc 4.4.5
configuration: --extra-version=4:0.6-2ubuntu6.2 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-vaapi --enable-pthreads --enable-zlib --enable-libvpx --disable-stripping --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-x11grab --enable-libdc1394 --enable-shared --disable-static
WARNING: library configuration mismatch
libavutil configuration: --extra-version=4:0.6-2ubuntu6.2 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-vaapi --enable-pthreads --enable-zlib --enable-libvpx --disable-stripping --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-x11grab --enable-libdc1394 --shlibdir=/usr/lib/i686/cmov --cpu=i686 --enable-shared --disable-static --disable-ffmpeg --disable-ffplay
libavcodec configuration: --extra-version=4:0.6-2ubuntu6.2 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-vaapi --enable-pthreads --enable-zlib --enable-libvpx --disable-stripping --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-x11grab --enable-libdc1394 --shlibdir=/usr/lib/i686/cmov --cpu=i686 --enable-shared --disable-static --disable-ffmpeg --disable-ffplay
libavformat configuration: --extra-version=4:0.6-2ubuntu6.2 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-vaapi --enable-pthreads --enable-zlib --enable-libvpx --disable-stripping --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-x11grab --enable-libdc1394 --shlibdir=/usr/lib/i686/cmov --cpu=i686 --enable-shared --disable-static --disable-ffmpeg --disable-ffplay
libavdevice configuration: --extra-version=4:0.6-2ubuntu6.2 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-vaapi --enable-pthreads --enable-zlib --enable-libvpx --disable-stripping --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-x11grab --enable-libdc1394 --shlibdir=/usr/lib/i686/cmov --cpu=i686 --enable-shared --disable-static --disable-ffmpeg --disable-ffplay
libavfilter configuration: --extra-version=4:0.6-2ubuntu6.2 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-vaapi --enable-pthreads --enable-zlib --enable-libvpx --disable-stripping --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-x11grab --enable-libdc1394 --shlibdir=/usr/lib/i686/cmov --cpu=i686 --enable-shared --disable-static --disable-ffmpeg --disable-ffplay
libswscale configuration: --extra-version=4:0.6-2ubuntu6.2 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-vaapi --enable-pthreads --enable-zlib --enable-libvpx --disable-stripping --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-x11grab --enable-libdc1394 --shlibdir=/usr/lib/i686/cmov --cpu=i686 --enable-shared --disable-static --disable-ffmpeg --disable-ffplay
libpostproc configuration: --extra-version=4:0.6-2ubuntu6.2 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-vaapi --enable-pthreads --enable-zlib --enable-libvpx --disable-stripping --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-x11grab --enable-libdc1394 --shlibdir=/usr/lib/i686/cmov --cpu=i686 --enable-shared --disable-static --disable-ffmpeg --disable-ffplay
libavutil 50.15. 1 / 50.15. 1
libavcodec 52.72. 2 / 52.72. 2
libavformat 52.64. 2 / 52.64. 2
libavdevice 52. 2. 0 / 52. 2. 0
libavfilter 1.19. 0 / 1.19. 0
libswscale 0.11. 0 / 0.11. 0
libpostproc 51. 2. 0 / 51. 2. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'music.m4a':
Metadata:
major_brand : M4A
minor_version : 0
compatible_brands: M4A mp42isom
Duration: 00:00:03.41, start: 0.000000, bitrate: 66 kb/s
Stream #0.0(und): Audio: aac, 44100 Hz, mono, s16, 63 kb/s
Output #0, mp3, to 'music.mp3':
Stream #0.0(und): Audio: 0x0000, 44100 Hz, mono, s16, 64 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Encoder (codec id 86017) not found for output stream #0.0
如何将.m4a
声音文件转换为.mp3
文件格式?
答案1
简单的方法是:
ffmpeg -v 5 -y -i input.m4a -acodec libmp3lame -ac 2 -ab 192k output.mp3
如果你想要一个脚本来包装它,请尝试aac2mp3,这应该对你有用。(最后一条语句的语法是从那里提取的。)内联代码如下:
#!/bin/bash
#
# $Id: aac2mp3,v 1.2 03/30/2008 10:00 Daniel Tavares ([email protected]) -
# Based on Script - rali Exp $
#
#
# Convert one or more AAC/M4A files to MP3. Based on a script example
# I found at: http://gimpel.gi.funpic.de/Howtos/convert_aac/index.html
#
ME=`basename ${0}`
FFMPEG="/usr/bin/ffmpeg"
EXT="mp4"
BITRATE="128"
do_usage() { # explanatory text
echo "usage: ${ME} [-b nnn] [-e ext] [-f] [-c] [-r] [-v] [-h] [file list]"
echo " Convert music from AAC format to MP3"
echo " -m /path/app Specify the location of ffmpeg(1)"
echo " -b nnn bitrate for mp3 encoder to use"
echo " -e ext Use .ext rather than .m4a extension"
echo " -f Force overwrite of existing file"
echo " -c Delete original AAC|M4A file(s)"
echo " -v Verbose output"
echo " -h This information"
echo ""
echo "For recursive directory, use: find -name '*.${EXT}' -exec ${ME} "{}" [args] \;"
exit 0
}
do_error() {
echo "$*"
exit 1
}
file_overwrite_check() {
if [ "$FORCE" != "yes" ]
then
test -f "${1}" && do_error "${1} already exists."
else
test -f "${1}" && echo " ${1} is being overwritten."
fi
}
create_mp3() { # use ffmpeg(1) to convert from AAC to MP3
file_overwrite_check "${2}"
test $VERBOSE && echo -n "Converting file: ${1}"
${FFMPEG} -v 5 -y -i "${1}" -acodec libmp3lame -ac 2 -ab ${BITRATE}k "${2}";
if [ $? -ne 0 ]
then
echo ""
echo "Error!"
do_cleanup
do_error "Exiting"
fi
test $VERBOSE && echo ". OK"
}
do_cleanup() { # Delete intermediate and (optionally) original file(s)
test ${RMM4A} && rm -f "${1}"
test $VERBOSE && echo ". OK"
}
do_set_bitrate() {
test $VERBOSE && echo -n "Setting bitrate to: $1 kbps"
BITRATE=$1
test $VERBOSE && echo ". OK"
}
GETOPT=`getopt -o l:m:b:e:cfhrv -n ${ME} -- "$@"`
if [ $? -ne 0 ]
then
do_usage
fi
eval set -- "$GETOPT"
while true
do
case "$1" in
-m) FFMPEG=$2 ; shift ; shift ;;
-b) do_set_bitrate $2 ; shift ; shift ;;
-e) EXT=$2 ; shift ; shift ;;
-f) FORCE="yes" ; shift ;;
-c) RMM4A="yes" ; shift ;;
-v) VERBOSE="yes" ; shift ;;
-h) do_usage ;;
--) shift ; break ;;
*) do_usage ;;
esac
done
test -f $FFMPEG || do_error "$FFMPEG not found. Use \"-m\" switch."
if [ $# -eq 0 ]
then # Convert all files in current directory
for IFILE in *.${EXT}
do
if [ "${IFILE}" == "*.${EXT}" ]
then
do_error "Not found ${EXT} in this folder."
fi
OUT=`echo "${IFILE}" | sed -e "s/\.${EXT}//g"`
create_mp3 "${IFILE}" "${OUT}.mp3"
do_cleanup "${IFILE}"
done
else # Convert listed files
for IFILE in "$*"
do
test -f "${IFILE}" || do_error "${IFILE} not found."
OUT=`echo "${IFILE}" | sed -e "s/\.${EXT}//g"`
create_mp3 "${IFILE}" "${OUT}.mp3"
do_cleanup "${IFILE}"
done
fi
exit 0
答案2
这对我而言在 Ubuntu 14.04 上有效:
avconv -i input.m4a ouptut.mp3
要获取avconv
命令,请安装libav 工具 :
sudo apt-get install libav-tools
答案3
声音转换器无需在命令行上乱搞就可以做到这一点,它可以在 Ubuntu 软件中心使用:
答案4
在 Ubuntu 20.04 中,原始命令开箱即用:
ffmpeg -i music.m4a music.mp3